:odd
или :even
селекторов. Обратите внимание, что jQuery индексируется с нулевой отметкой, что означает, что первый элемент в элементе выбора имеет позицию 0. Это может быть немного запутанным, как, напротив, интуитивно :odd
выбирает второй элемент (позиция 1), четвертый элемент (позиция 3) , и так далее. Вот как вы бы нацеливали все нечетные элементы с помощью target
$(".target:odd").addClass("animated shake");
класса и давали им классы: $(".target:odd").addClass("animated shake");
Попробуйте выбрать все четные target
элементы и дать им классы animated
и shake
. Помните, что даже относится к позиции элементов с нулевой системой в виду.
target
elements that jQuery considers to be even should shake.
testString: assert($('.target:even').hasClass('animated') && $('.target:even').hasClass('shake'));
- text: You should use the :even
selector to modify these elements.
testString: assert(code.match(/\:even/g));
- text: Only use jQuery to add these classes to the element.
testString: assert(code.match(/\$\(".target:even"\)/g) || code.match(/\$\('.target:even'\)/g) || code.match(/\$\(".target"\).filter\(":even"\)/g) || code.match(/\$\('.target'\).filter\(':even'\)/g));
```