how do I add event handlers to each individual item items?
I’m trying to add a onclick event to call theMethod, and at the same time, it will pass it an id to tell the javascript which item id was clicked.
function theMethod(id) {
}
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.
The code in
theMethod(id)could also just be placed inside the anonymous function attached to theclickevent for thelielements.The above code assumes that each of the
li‘s have their own unique ID.