我有这样一个函数:
$('img#foo').load(function(){
// do something
$(this).attr('src',newsrcurl) ;
}) ;
SRC 改变导致重新调用加载函数,所以无限循环!
如何停止加载绑定(bind)?
最佳答案
使用 .one()
附加 'load' 处理程序将确保它只触发一次。
$('img#foo').one('load', function(){
// do something
$(this).attr('src',newsrcurl) ;
}) ;
关于javascript - 当 IMG.SRC 更改时,jQuery Load() 会导致无限循环,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14302695/