jQuery:使用.load()附加到图像的函数永远不会在IE中调用

时间:2010-12-11 01:20:15

标签: javascript internet-explorer load jquery

我正在为要加载图像时要执行的图像附加一个函数:

this.img.load( function(self){ return function(){
   self.ready = true;
   // more code
}; }(this) );

this是一个对象,this.img是图像对象。在Internet Explorer中,永远不会调用该函数。它在Safari,Firefox和Chrome中运行良好。

我对IE不是很熟悉,我真的很感激帮助。完整来源here(第125行)。

2 个答案:

答案 0 :(得分:2)

尝试在将src-attribute分配给img-object之前分配load-method。

答案 1 :(得分:1)

@travelboy。 Jquery有一个加载方法。

http://api.jquery.com/load-event/

您是否检查了4该特定事件?

$('img.userIcon').load(function(){
  if($(this).height() > 100) {
    $(this).addClass('bigImg');
  }
});