how to remove html tag in contenteditable with selection text
function testdemo() {
//what is next
....
}
Before :
<button onclick="testdemo();">RUN</button>
<div id="test" contenteditable="true">
<b>Lorem ipsum</b> dolor sit amet, <span style="color:red;">ea ignota verear</span> quaerendum
</div>
After :
<div id="test" contenteditable="true">
Lorem ipsum dolor sit amet, ea ignota verear quaerendum
</div>
Thank you in advance
Try this:
JS:
function testdemo() {
var div = document.getElementById('test');
div.innerHTML = div.textContent;
}
Jquery:
function testdemo() {
$('#test').html($('#test').text());
}
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