:nth-child(even) and :even in jquery are looking similar but selecting different elements. Please let me know the differences.
Happy Coding…
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.
Here is an example to illustrate the difference:
http://jsfiddle.net/bEfT6/
:evenmatches every 2nd element within the set of elements you are selecting. Where as:nth-child(even)matches any elements which are an even numbered child of their respective parent.So in the example, you see that the two selectors affect different elements. The elements with red text match the selected class and are even numbered children of the parent div. The ones with blue background match the selected class and are even within that selection.
So:
matches every element with the class
somethingwhich is an even child of it’s parent.matches every other element with the class
something. (regardless of relation to its siblings)