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.
<!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>