<!DOCTYPE html>
<html>
<body>
<h1>The Element Object</h1>
<h2>The contentEditable Property</h2>
<p id="myP" contenteditable="true">Try to change this text.</p>
<button onclick="myFunction(this);">Disable "myP" to be editable!</button>
<p id="demo"></p>
<script>
function myFunction(button) {
const x = document.getElementById("myP");
if (x.contentEditable == "true") {
x.contentEditable = "false";
button.innerHTML = 'Enable "myP" p to be editable!';
} else {
x.contentEditable = "true";
button.innerHTML = 'Disable "myP" to be editable!';
}
}
</script>
</body>
</html>