Get Section Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Section

Introduction

The Section object represents an HTML <section> element.

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<section id="mySection">
  <h1>Section Heading</h1>
  <p>Some text in section..</p>
</section>/*from  w w  w. j av  a  2 s.c om*/

<button onclick="myFunction()">set the text color of the section content</button>

<script>
function myFunction() {
    var x = document.getElementById("mySection");
    x.style.color = "blue";
}
</script>

</body>
</html>

Related Tutorials