HTML DOM alt 屬性
定義和用法
alt 屬性可設(shè)置或返回在瀏覽器不支持文本域時顯示的替代文本。
語法
textObject.alt=alternate_text
實例
下面的例子可返回文本域的 alt 文本:
<html>
<body>
<form>
Email: <input type="text" alt="Email input field" id="email" />
</form>
<p>The alt text for the text field is:
<script type="text/javascript">
x=document.getElementById('email');
document.write(x.alt
);
</script></p>
</body>
</html>