Example is this and this is not working. What is my mistake ?
var i=1;
for(i; i <=165; i++){
jQuery(".tekAlan"+i).click(function() {
jQuery(".tekAlan"+i).addClass("tekAlanSecildi");
});
}
Thanks.
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.
I guess you want to add to only the clicked item the class. However, it always adds the class to the last one. That’s because i is accessed after the end of the for, so it always contains 165. Do this to solve your problem:
jQuery(this)is a reference of the element affected by the event (in this case,click)