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).
精彩评论