Jquery remove everything except for bolded

Viewed 267

I have html like this:

<div id="divTestArea1">
    <b>Bold text</b>
    <i>Italic text</i>
    <div id="divTestArea2">
            <b>Bold text 2</b>
            <i>Italic text 2</i>
            <div>
                    <b>Bold text 3</b>
            </div>
    </div>

and I would like to remove all elements that aren't bold. I've tried with this code:

$('*:not(b)').remove();

and a couple other variations but they all either error out or remove everything. btw, are jquery selectors and jsoup selectors 100% compatible? I'd like to use the answer to this in jsoup as well.

5 Answers
Related