JQuery .load() does not fire? here is the solution!

Last time I was developing my sequence viewer plugin for wordpress I was having some trouble loading the player. I was using the JQuery .load() function to start the player as soon as the images where loaded. But the .load() function did not fire every time. Sometimes I had to refresh the page 2 times before it would fire.

I was searching around and I found this peace of code which worked for me. And it works in all browsers!

{code type=xml}
$(“#Img”).one(“load”,function(){
//image is loaded
})
.each(function(){
if(this.complete || (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6))
$(this).trigger(“load”);
});
{/code}