本文介绍了如何使用jQuery删除HTML和特殊字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< p>< p>< p>< ; table border =0cellpadding =1cellspacing =0> < tbody>< tr valign =top>< td class =headlines>•< / td>< td class =headlines>< a href = target =_ top> SOME TEXT< / a>< / td>< / tr> < / tbody>< / table>
将链接文本封装到段落标签中的div或位置会很好。
有什么想法?
解决方案这个答案发布后。
请参阅 @ TJ's answer 为新问题提供解决方案。
使用— gasp,shock horror — 香草JavaScript !
var $ headlines = $('。headlines'), headlineText = $ headlines.text(), replaceText = headlineText.replace /•/G, ''); $ headlines.text(replaceText);或者稍微性感的语法: '$'$>'$'$'$'$'$'$'$'$'$'$''); });
So what I want to do is remove all of the HTML table tag elements, leaving the link tags alone.
<table border="0" cellpadding="1" cellspacing="0"> <tbody><tr valign="top"><td class="headlines">•</td><td class="headlines"><a href="" target="_top">SOME TEXT</a></td></tr> </tbody></table>It would be nice to wrap the linked text into a div or place in a paragraph tag.
Any thoughts?
解决方案The question was changed to ask something completely different after this answer was posted.
See @T.J.'s answer for a solution to the new question.
Do it with — gasp, shock horror — vanilla JavaScript!
var $headlines = $('.headlines'), headlineText = $headlines.text(), replaceText = headlineText.replace(/•/g, ''); $headlines.text(replaceText);or, slightly sexier syntax:
$('.headlines').text(function (index, text) { return text.replace(/•/g, ''); });
更多推荐
如何使用jQuery删除HTML和特殊字符?
发布评论