jquery - running javascript after page has been loaded -


this question has answer here:

i have javascript file call in view page in data information display. @ same time have piece of javascript shows menu bar once image has been clicked. scripted being ran before page loaded or because not working. how can make piece of javascript take action after other scripts have completed running , page loaded? tried not working right

javascript

(function ($) {  .... lines load view page data  $(document).ready(function () {     $('figure').on('click', function (event) {         $(event.currenttarget).toggleclass('open');     }); });  })(jquery); 

you use $(window).on("load") instead of $(document).ready if want wait until elements have loaded in case:

$(window).on("load", function(){     $('figure').on('click', function (event) {         $(event.currenttarget).toggleclass('open');     });     }); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -