HTML DOM alt 属性

定义和用法

alt 属性可设置或返回在浏览器不支持单选按钮时显示的替代文本。

语法

radioObject.alt=alternate_text

实例

下面的例子可返回单选按钮的 alt 文本:

<html>
<body>

<form>
Male: <input id="male" alt="male" type="radio"
name="Sex" value="Male" />
<br />
Female: <input id="female" alt="female" type="radio"
name="Sex" value="Female" />
</form>

<p>The alt text for the radio buttons are:
<script type="text/javascript">
document.write(document.getElementById('male').alt);
document.write(" and ");
document.write(document.getElementById('female').alt);
</script></p>

</body>
</html>
VUE