Javascript DOM HTML Summary Object get

Introduction

The Summary object represents an HTML <summary> element.

We can access a <summary> element via document.getElementById():

var x = document.getElementById("mySummary");

Click the button to get the HTML content of the summary element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<details>
  <summary id="mySummary">Copyright 2020-2024.</summary>
  <p> - by java2s.com. All Rights Reserved.</p>
</details>//from  w  w w. jav  a2s  .co  m
<button onclick="myFunction()">Test</button>
<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("mySummary").innerHTML;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>



PreviousNext

Related