css - jQuery on load event do not trigger script -
first looking @ onload
event, when read it, discovered or going deprecated, search , found info use on
event check if image loaded:load() method deprecated?
but simple animation trigger, not work. element not visible. works if reload browser. animation worked perfect until added load event. wrong , how can improve code work better?
$("#intro-img").on("load", function() { $(".intro-content").animate({ left: '20px', opacity: '1.0' }); });
edit: script running after used window
instead of id. $(window).on("load", function() {....
script should run when content on page has been loaded? guess there never guarantee work 100% images!?
$('#book').on("load",function(){ //animate });
problem approach when image loaded cache load event has possibility never triggered.when image first downloaded jquery can have chance attach event before image loaded , work expected.but if image loaded via cache jquery may not have.
$('#book').on("load",function(){ $(".intro-content").animate({ left: '20px', opacity: '0.5', height:"300px" }); }).each(function(){ if(this.complete) { $(this).trigger('load'); } });
this code attaches event , checks whether image loaded , triggers load event.
Comments
Post a Comment