We can create a <hr> element via the document.createElement()
method:
var x = document.createElement("HR");
Click the button to create a HR element.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <script> function myFunction() {/* w w w . j ava 2 s.co m*/ var x = document.createElement("HR"); document.body.appendChild(x); } </script> </body> </html>