如何在 JavaScript 中获取链接的 type 属性值?
htmljavascriptprogramming scripts更新于 2026/1/10 9:48:17
要在 JavaScript 中获取链接的 type 属性值,请使用 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>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

