Kaleem Sajid
Kaleem Sajid

Reputation: 230

Function only executes when refresh the page, not on first load

I ran into this strange issue, I hope someone will be able to help.

var k_img = jQuery('#'+c['id']).parents('.PhotoCommentImage').children('.PhotoCommentImg');

k_img[0].onload = (function() {

//these statements only executes when refresh the page, not on first load.

});

What I am trying to do is to execute statements when an image is finished loading. The strange thing here is that these statements only executes when we load the page. If we refresh the page it works fine.

Thanks in advance.

Upvotes: 0

Views: 450

Answers (1)

dcclassics
dcclassics

Reputation: 896

Since you're using jQuery, please try $(k_img[0]).bind('load', function() { // });

Upvotes: 1

Related Questions