我有一段:
<p id="demo">Hi <b>R</b><u>o</u><i>h</i>it! It's soo good to see you</p>
如何以相同的格式替换Rohit一词和Akshat,以便我得到: 嗨 A k s 帽子!很高兴见到你
答案 0 :(得分:1)
您可以执行以下操作:
var content = document.getElementById('demo').textContent;
document.getElementById('demo').textContent = content;
&#13;
<p id="demo">Hi <b>R</b><u>o</u><i>h</i>it! It's soo good to see you</p>
&#13;
答案 1 :(得分:0)
请看一下
var text = $(&#39; #demo&#39;)。text();
的console.log(文本); //返回&#34;嗨罗希特!很高兴见到你&#34;