Reputation: 851
How would I go about getting the first instance of an INS element OR the first instance of a DEL element depending on which is displayed first?
Using jQuery, I can get the first of each element in a div using this:
$("#output").find("ins").first();
$("#output").find("del").first();
In the following html:
<div id="output">
This is some text with some <ins>added text</ins> or maybe some <del>deleted text</del>
</div>
I'd like to get the INS element because it appears first.
But in this version:
<div id="output">
This is some <del>deleted text</del> and also some <ins>added text</ins>.
</div>
I'd like to get the DEL element because it appears first.
Any thoughts?
Upvotes: 0
Views: 93
Reputation: 8246
If it's always the first element within #output, then you could do:
$('#output > *').eq(0)
Upvotes: 0