Let's say we have a div as follows
<div id = "container" >
<p contenteditable="false">Hello World</p>
<button onclick="alert();"></button>
</div>
and we retrieved the content of the div and saved it into a variable
var content = document.getElementById("container").innerHTML;
Now we want to remove the contenteditable="false" and the onclick="alert();"
I have tried the following:
content = content.replace('contenteditable="false"','');
content = content.replace('onclick="alert();"','');
and then put the content back inside
document.getElementById("container").innerHTML = content;
but this did not work for me.