Javascript DOM HTML Paragraph Object delete inner html

Introduction

Delete the HTML content of a <p> element with id="demo":

View in separate window

<!DOCTYPE html>
<html>
<body>

<p id="demo">Click the button to delete my HTML content (innerHTML).</p>

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

<script>
function myFunction() {/*from  ww  w. j a  v a  2 s.  c  om*/
  document.getElementById("demo").innerHTML = "";
}
</script>

</body>
</html>



PreviousNext

Related