Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
182
rated 0 times [  187] [ 5]  / answers: 1 / hits: 73356  / 13 Years ago, mon, march 28, 2011, 12:00:00

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!


More From » jquery

 Answers
27

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.



Corrected :
http://jsfiddle.net/rY6Gq/1/



Faulty one with double alert:
http://jsfiddle.net/rY6Gq/


[#93041] Friday, March 25, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
zoey

Total Points: 120
Total Questions: 103
Total Answers: 105

Location: Marshall Islands
Member since Mon, May 31, 2021
3 Years ago
;