:odd
ou :even
seletores :even
. Note que o jQuery é zero-indexado, o que significa que o primeiro elemento em uma seleção tem uma posição 0. Isso pode ser um pouco confuso, pois, intuitivamente :odd
seleciona o segundo elemento (posição 1), quarto elemento (posição 3) , e assim por diante. Aqui está como você iria direcionar todos os elementos ímpares com a classe target
e dar-lhes classes: $(".target:odd").addClass("animated shake");
Tente selecionar todos os elementos do mesmo target
e dar a eles as classes de animated
e shake
. Lembre-se que até se refere à posição dos elementos com um sistema baseado em zero em mente. target
que o jQuery considera serem pares devem se movimentar.
testString: 'assert($(".target:even").hasClass("animated") && $(".target:even").hasClass("shake"), "All of the target
elements that jQuery considers to be even should shake.");'
- text: 'Você deve usar o seletor :even
para modificar esses elementos.'
testString: 'assert(code.match(/\:even/g), "You should use the :even
selector to modify these elements.");'
- text: Use apenas o jQuery para adicionar essas classes ao elemento.
testString: 'assert(code.match(/\$\(".target:even"\)/g) || code.match(/\$\(".target:even"\)/g) || code.match(/\$\(".target"\).filter\(":even"\)/g) || code.match(/\$\(".target"\).filter\(":even"\)/g), "Only use jQuery to add these classes to the element.");'
```