Document links Collection - Add a red border to the first link in the document: - Javascript DOM

Javascript examples for DOM:Document links

Description

Document links Collection - Add a red border to the first link in the document:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<p>
  <a href="/html/default.asp">HTML</a><br>
  <a href="/css/default.asp">CSS</a>
</p>//from   w  w w. j  a v  a2 s .com

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {
    document.links[0].style.border = "5px solid red";
}
</script>

</body>
</html>

Related Tutorials