Get BR Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:BR

Introduction

The BR object represents an HTML <br> element.

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

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<div>
This is a test. This is a test. This is a test.
This is a div <br id="myBR"> element with some <br> line breaks.
This is a test. This is a test. This is a test.

</div>//  ww w.  ja  va  2s.  co  m

<button onclick="myFunction()">Hide the first BR element</button>

<script>
function myFunction() {
    var x = document.getElementById("myBR");
    x.style.display = "none";
}
</script>

</body>
</html>

Related Tutorials