Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing all line-breaks (BRs)

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.

like image 473
eozzy Avatar asked Dec 07 '09 05:12

eozzy


2 Answers

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?

like image 79
Wesley Petrowski Avatar answered Nov 03 '22 19:11

Wesley Petrowski


The best way to do it would be...

$('#id p br').remove();
like image 28
alex Avatar answered Nov 03 '22 17:11

alex