开发者

Removing all line-breaks (BRs)

I'd like to remove all <br/> <br /> or <br> tags from #id p. I tried $('#id p').f开发者_高级运维ind('br').remove(); but it doesn't seem to work.


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?


The best way to do it would be...

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


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜