How with jQuery/Javascript count the elements by class and set another class a certain element in the list.
It is possible?
An example, i have four elements with the class “qa” and change or add class “qa2” second element in list.
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.
Using jquery
To add a class to the 2nd element
Inside a loop to add class to 2nd element using condition.
Or this will add ‘newClass’ class to all elements that has class ‘cls’
OR this will add different classes to odd and even items in the list/matched items