jquery - running javascript after page has been loaded -
this question has answer here:
- javascript executes after page load 21 answers
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
Post a Comment