Nir*_*ana 0 html javascript regex tags jquery
我想为我的textarea创建一个"清除"按钮,它将删除每个<>以及它们之间的任何内容.
所以我要说:
<div id="markred">Hello World! My name is <b>John!</b></div>
Run Code Online (Sandbox Code Playgroud)
在"清洁"功能之后,我希望它是:
Hello World! My name is John!
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚如何做到这一点,尝试了几个正则表达式,然后意识到我真的不知道怎么写正常的正则表达式...
任何帮助将非常感激!
使用text()之类的,
alert($('#markred').text());// will give only text not html tags
Run Code Online (Sandbox Code Playgroud)
或者,
$('#markred').text(function(){
return $(this).text();// will remove <b> tag
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
84 次 |
| 最近记录: |