Question

I'd like to remove all <br/> <br /> or <br> tags from #id p. I tried $('#id p').find('br').remove(); but it doesn't seem to work.

Was it helpful?

Solution

The best way to do it would be...

$('#id p br').remove();

OTHER TIPS

I tried out this example, and it worked for me:

<html>
<head>
    <title>Test!</title>
    <script src="jquery-1.3.2.js"/>
</head>
<body>
    <div id="foobar">
        <p>
            This is <br/> some <br/> text.
        </p>
    </div>
    <input type="button" value="Click" onclick="$('#foobar p').find('br').remove();"/>
</body>
</html>

Is there anything different from what you are trying to do?

Are you trying to search for BR tage within a paragraph with a particular ID? If so, I think that would be that would be p#id instead (I'm no JQuery expert, but it tends to follow CSS selectors).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top