views:

197

answers:

1

ie. i have the following:

<div class="myclass">my text1</div>
some other code+containers...

<div class="myclass">my text2</div>
some other code+containers...

<div class="myclass">my text3</div>
some other code+containers...

i have the css class div.myclass {doing things} that applies to all obviously but i also wanted to be able to select the first, second or third like this:

div.myclass:first {color:#000;} 
div.myclass:second {color:#FFF;} 
div.myclass:third {color:#006;}

almost like the jQuery index selection .eq( index ) which is what i am using currently but need a noscript alternative. Thanks in advance!

+1  A: 

How about the CSS's nth-child, did you try that....?

Note: This works in modern browsers only

Sarfraz
That note seems to be synonymous to "No IE".
extraneon
@extraneon: Yup, you got it right :)
Sarfraz
This would not work since there are no uniform parent containers, which is why i wanted to select based on class name occurrence rather. I would have to look at each and every instance and find out the parent tag,id or class in order to select the child. Doing which does not give me uniformity and is difficult to read and would also need to be updated if parent objects/attributes change.
Tumharyyaaden