Javascript DOM HTML Anchor type Property set

Introduction

Set the type attribute of a link to text/html:

document.getElementById("myAnchor").type = "text/html";

Click the button to set the value of the type attribute of the link to "text/html".

View in separate window

<!DOCTYPE html>
<html>
<body>

<p><a id="myAnchor" href="https://www.java2s.com">Examples</a></p>

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

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

<script>
function myFunction() {/*from   www  . java2s.c o  m*/
  document.getElementById("myAnchor").type = "text/html";
  document.getElementById("demo").innerHTML = "The value of the type attribute of the link changed.";
}
</script>

</body>
</html>



PreviousNext

Related