Anchor type Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Anchor


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>

<p><a type="text/html" id="myAnchor" href=""></a></p>

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

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

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


Related Tutorials