I made a jsfiddle of the problem
the problem is whatever item I click it keeps showing me the last id(which is 10)
This’s driving me crazy! Help
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s because you are alerting a predefined variable. In your for loop you are updating the value of the
idvariable, in last iteration it’s value become10and you are alerting this variable in each element’s click handler. You should usethis.id:http://jsfiddle.net/2dfkh/
Note that event in your code is
undefined.