我遇到了这个奇怪的问题,希望有人能够帮忙。
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.
});
我想做的是在图像加载完成时执行语句。这里奇怪的是,这些语句仅在我们加载页面时执行。如果我们刷新页面,它就可以正常工作。
提前致谢。
最佳答案
由于您使用的是 jQuery,请尝试 $(k_img[0]).bind('load', function() {//});
关于javascript - 函数仅在刷新页面时执行,而不是在首次加载时执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23401378/