So, I have an HTML string that looks just like this:
<div>
<div class="venue-tooltip">
Filling station
<div>
<a class="manage-venue-details" rel="venue-id-10" href="javascript:void(0);">Add filling station info</a>
</div>
</div>
</div>
I want to get all the contents without the “a” element, so basically to have something like this:
<div>
<div class="venue-tooltip">
Filling station
<div>
</div>
</div>
</div>
The HTML is loaded in a js string and I have tried those variants:
$(':not(a)', myHtmlString);
$(myHtmlString).not('a');
Both of them return unfiltered HTML. Any ideas?
My jQuery version is 1.6.1 and I test the above with Firefox 6
You cannot use DOM manipulation functions to change a string. Try using regular expresions:
It’s more efficient than convert string in DOM, manipulate and then convert it again in again in a string.