Javascript DOM HTML HR Object get

Introduction

The HR object represents an HTML <hr> element.

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

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

Click the button to hide the HR element.

View in separate window

<!DOCTYPE html>
<html>
<body>
<hr id="myHR">
<button onclick="myFunction()">Test</button>

<script>
function myFunction() {//w  ww  . j  ava  2 s  .  co m
  var x = document.getElementById("myHR");
  x.style.display = "none";
}
</script>

</body>
</html>



PreviousNext

Related