Menu

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 elements and giving them the classes of animated and shake.

Run tests (ctrl + enter)
Reset Help Bug
All the target elements that computer considers even should shake.
You should use the :even function to modify these elements.
Only use jQuery to add these classes to the element.

1

2

3
$(document).ready(function() {
4
$(“#target1”).css(“color”, “red”);
5
$(“#target1”).prop(“disabled”, true);
6
$(“#target4”).remove();
7
$(“#target2”).appendTo(“#right-well”);
8
$(“#target5”).clone().appendTo(“#left-well”);
9
$(“#target1”).parent().css(“background-color”, “red”);
10
$(“#right-well”).children().css(“color”, “orange”);
11
$(“#left-well”).children().css(“color”, “green”);
12
$(“.target:nth-child(2)”).addClass(“animated bounce”);
13

14
});
15

16

17

18

19

20

jQuery Playground

21

22
23

#left-well

24

25
#target1
26
#target2
27
#target3
28

29

30

31

#right-well

32

33
#target4
34
#target5
35
#target6
36

37

38

39

40