rolandnsharp
rolandnsharp

Reputation: 281

selecting specific ordered lists

I have a wikipedia API returning html with multiple non-classed ol's. eg.

<div id = "wikiInfo">
  <ol></ol>
  <p></p>
  <ol></ol>
  <p></p>
  <ol></ol>

</div>

So I want to single out only the first two and extract the text.

I have managed to select only the ol's but for some reason I can's get n'th child working with ol's

$('#wikiInfo').find("div ol:nth-child(-n+2)").css({"color":"red","border":"2px solid red"});

Any ideas?

Upvotes: 1

Views: 37

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388316

Try

$('#wikiInfo').children("ol:lt(2)").css({"color":"red","border":"2px solid red"});

Demo: Fiddle

Upvotes: 2

Related Questions