我正在开发一个文本编辑器,其中的内容可以采用以下形式
<div>some text <strong>bold text</strong> more <em>italic</em></div>
现在在某些用户点击时,我必须从 div 中删除粗体和斜体样式。
如何从 div 中删除 strong 和 em 标签?
谢谢
卡 PIL
最佳答案
HTML
<div id="foo">
<div>some text <strong>bold text</strong> more <em>italic</em></div>
</div>
JS
var t = document.getElementById('foo').innerHTML;
t = t.replace('<strong>', '');
t = t.replace('</strong>', '');
t = t.replace('<em>', '');
t = t.replace('</em>', '');
document.getElementById('foo').innerHTML = t;
关于javascript - 如何在 div 中获得粗斜体样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5739983/