下了个插件 发现引发了2次onchange事件
找到代码如下
没有看明白 field.change(toCheck).focus(toExp);这个是什么意思怎么修改不引发2次onchange事件? $.each(settings.items, function(){
var field = $("[name='"+this.name+"']",formObj[0]);
var obj = this,
toExp = function(){showExp(obj);},
toCheck = function(){ isAll=false; fieldCheck(obj);};
if(field.is(":file") || field.is("select")){
field.change(toCheck).focus(toExp);
}else{
field.blur(toCheck).focus(toExp);
}
});
找到代码如下
没有看明白 field.change(toCheck).focus(toExp);这个是什么意思怎么修改不引发2次onchange事件? $.each(settings.items, function(){
var field = $("[name='"+this.name+"']",formObj[0]);
var obj = this,
toExp = function(){showExp(obj);},
toCheck = function(){ isAll=false; fieldCheck(obj);};
if(field.is(":file") || field.is("select")){
field.change(toCheck).focus(toExp);
}else{
field.blur(toCheck).focus(toExp);
}
});
我不明白代码那里为什么要引发一次 onchange事件
引发了一个事件
不明白这里为什么要主动引发一个事件 focus 不能用其他方式实现吗