【发布时间】:2011-10-08 07:19:19
【问题描述】:
我的 HTML 中有 1 按钮和一些文本,如下所示:
function get_content(){
// I don't know how to do in here!!!
}
<input type="button" onclick="get_content()" value="Get Content"/>
<p id='txt'>
<span class="A">I am</span>
<span class="B">working in </span>
<span class="C">ABC company.</span>
</p>
当用户点击按钮时,<p id='txt'>中的内容会变成如下预期结果:
<p id='txt'>
// All the HTML element within the <p> will be disappear
I am working in ABC company.
</p>
谁能帮助我如何编写 JavaScript 函数?
谢谢。
【问题讨论】:
-
这能回答你的问题吗? Strip HTML from Text JavaScript
标签: javascript html