I'd like to keep the first <a>
and the <span>
, but remove the rest in the following:
<div>
<a href="http://aerospace.com">Aerospace</a> and
<a href="http://aviation.com">Aviation</a>
<span class="blah">(15)</span>
</div>
What I'm finding is that there doesn't seem to be an obvious of matching the plain text and
. I'm trying to use nextAll() with a filter:
$("a:contains('Aerospace')").each(function() {
$(this).nextAll().filter(":not(span)").empty();
});
But the and
text is left there.
Is it possible to match text in jQuery? Is there such a thing as a text selector so I could use something like filter (":isText()")
?