jQuery更改事件被调用两次 [英] jQuery change event being called twice
本文介绍了jQuery更改事件被调用两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有一些输入和选择框的表单,每个都有 class =myClass
。我还有以下脚本:
I have a form with some input and select boxes, each has class="myClass"
. I also have the following script:
$(document).ready(function() {
$(".myClass").change(function() {
alert('bla');
})
});
我不明白为什么每次在选择框或输入框中进行更改后,都会调用该函数两次。
这里有什么不对?
I dont understand why after each change in select box or input box, this function is being called twice. What's wrong here?
感谢您的帮助!
Appreciate your help!
推荐答案
<我能想到的是,你在表格本身上使用了同一个班级。如果是这样,请从表单标记中移除myClass样式。
All I can think of is that you used the same class on the form itself. if so, remove the myClass style from your form tag.
更正后:
http://jsfiddle.net/rY6Gq/1/
双重警报错误:
http://jsfiddle.net/rY6Gq/
这篇关于jQuery更改事件被调用两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文