Get Summary Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Summary

Introduction

The Summary object represents an HTML <summary> element.

You can access a <summary> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<details>
  <summary id="mySummary">Copyright 2020-2030.</summary>
  <p> - by java2s.com. All Rights Reserved.</p>
</details>/*  w  ww .  j  a va2 s . co m*/

<button onclick="myFunction()">get the HTML content of the summary element</button>

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

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

</body>
</html>

Related Tutorials