Anchor type Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor

Description

The type property sets or gets the value of the type attribute of a link.

The type attribute sets the MIME type of the target URL in the area.

Set the type property with the following Values

Value Description
MIME-type Sets the MIME type of the linked document.

Return Value

A String, representing the MIME type of the linked document

The following code shows how to Return the MIME type of a specific link:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

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

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

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

<script>
function myFunction() {/*from  www  . j  a va  2s. co  m*/
    var v = document.getElementById("myAnchor").type;
    document.getElementById("demo").innerHTML = v;
}
</script>

</body>
</html>

Related Tutorials