Javascript DOM HTML Element contentEditable Property get

Introduction

Find out if a <p> element is editable or not:

var x = document.getElementById("myP").contentEditable;

View in separate window

<!DOCTYPE html>
<html>
<body>

<p id="myP" contenteditable="true">Click the button to find out if I am editable.</p>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from  w  w  w  . jav a2s.  c o  m*/
  var x = document.getElementById("myP").contentEditable;
  document.getElementById("demo").innerHTML = x + " = The p element is editable.";
}
</script>

</body>
</html>



PreviousNext

Related