ในการรับค่าแอตทริบิวต์ type ของลิงก์ใน JavaScript ให้ใช้ type คุณสมบัติ. แอตทริบิวต์ type ใช้เพื่อบอกว่าเอกสารเป็น html (text/html) หรือ css (text/css) เป็นต้น
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อรับค่าของแอตทริบิวต์ type ของลิงก์
<!DOCTYPE html>
<html>
<body>
<p><a id="anchorid" type="text/html" target= "_blank" href="https://www.qries.com/">Qries</a></p>
<script>
var myVal = document.getElementById("anchorid").type;
document.write("Value of type attribute: "+myVal);
</script>
</body>
</html>