Am working on a text editor where the content can be in the form of following
<div>some text <strong>bold text</strong> more <em>italic</em></div>
Now on some user click, I have to remove the bold and italic styling from the div.
How can I remove the strong and em tags from a div?
Thanks
Kapil
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With