代码示例:(标识:htmldom_anchor_type_2)
<!DOCTYPE html>
<html>
<body>

<p><a id="myAnchor" href="https://www.sou-xun.com">(www.sou-xun.com)</a></p>

<p>点击按钮,可将上面链接的 type 属性的值设置为 “text/html”。</p>

<button onclick="myFunction()">试一试</button>

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

<script>
function myFunction() {
  document.getElementById("myAnchor").type = "text/html";
  document.getElementById("demo").innerHTML = "上面链接的 type 属性的值现在是 “text/html”。";
}
</script>

</body>
</html>
运行结果: