English 中文(简体)
j 图像负荷
原标题:jquery image load strange behaviour

我有一页,有一只 im器,有:

<img src="someimage.jpeg" alt="image" class="show_image"/>

如今,用法律对图像进行更新......

$( .show_image ).attr( src ,  anotherimage.jpeg );

如今,图像被装上了,想操作一些法典......

as image scaling and letting the user know image is loaded

i 操作该密码了解图像......

 var inc = 0;
    $( .show_image ).load(function() {
        inc++;
        console.log( image loaded  +inc);
    });

如今,上述负荷功能不断更新,这表明了一种奇怪的情况。

行为和被称作rc体更新次数......

页: 1

pradyut.dyndns.org/original_image.jsp#imgid=202

i 认为必须照此办理。

if(inc==1) {
  //run code
}

任何帮助

增 编

最佳回答

http://api.jquery.com/one/“rel=“nofollow” Query s one( 方法:

$( .show_image ).one( load , function() {
    inc++;
    console.log( image loaded  +inc);
});

这在手工业首次运行后便搬走。

问题回答

装货单只一次装上图像,而不是每次装上新形象。

或者,使用<代码>unbind方法,在装订新的负荷活动之前,将以往的任何负荷活动统一起来。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签