HTML:
<div class="some-class">
<p>First element</p>
<p>Second element</p>
<p>Third element</p>
</div>
jQuery:
$('.some-class p:eq(1)' ).css('color', 'red');
------------------------------------------------------------------
jQuery pseudo-class :eq(i) targets the i-nd occurence
of the obeject selected. Counts start on zero (JavaScript based)
Argument i can be a math expression like:
($('p').size() - 1)/2) // founds the middle of a odd number of paragraphs
Maujor
-----Mensagem Original-----
De: "gepa" <[EMAIL PROTECTED]>
Para: "jQuery (English)" <jquery-en@googlegroups.com>
Enviada em: sexta-feira, 26 de setembro de 2008 11:44
Assunto: [jQuery] add a new class for middle element
Hello
I really like this script.
I was wondering , how would be possible to add a class to the middle
element ?!
I mean, by default there are always 3 elements, and i would like the
middle one to be different (to add it some css style).
Thanks.