Solve problem "Target Even Numbered Elements Using jQuery" online - Learn Python 3 - Snakify

Lesson: jQuery

Target Even Numbered Elements Using jQuery

You can also target all the even-numbered elements.

Here's how you would target all the odd-numbered elements with class target and give them classes:

$(".target:odd").addClass("animated shake");

Note that jQuery is zero-indexed, meaning that, counter-intuitively, :odd selects the second element, fourth element, and so on.

Try selecting all the even-numbered target elements and giving them the classes of animated and shake. Even-numbered is defined here with a zero-index in mind.


The content on this page is licensed under Attribution-ShareAlike 4.0 International. Original authors: freeCodeCamp, the content was modified.