KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
How can I select a certain element in a list of elements? I have the following: <div class="myclass">my text1</div> <!-- some other code follows --> <div> <p>stuff</p> </div> <div> <p>more stuff</p> </div> <p> <span>Hello World</span> </p> <div class="myclass">my text2</div> <!-- some other code follows --> <div> <p>stuff</p> </div> <p> <span>Hello World</span> </p> <input type=""/> <div class="myclass">my text3</div> <!-- some other code follows --> <div> <p>stuff</p> </div> <footer>The end</footer> 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 div of class .myclass like this, regardless of where they are in the markup : 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 I need a no-script alternative. To be specific, I am looking for pseudo selectors, not things like adding another class or using IDs to make things work.
Tags (comma-separated)
Save Edits
Cancel