HTML DOM alt 属性
定义和用法
alt 属性可设置或返回浏览器不支持 checkbox 时显示的替代文本。
语法
- checkboxObject.alt=alternate_text
实例
下面的例子返回了 checkbox 的替代文本:
- <html>
- <body>
- <form>
- I have a bike: <input id="bike" alt="bike" type="checkbox" name="Bike" />
- <br />
- I have a car: <input id="car" alt="car" type="checkbox" name="Car" />
- </form>
- <p>The alt text for the checkboxes are:
- <script type="text/javascript">
- document.write(
document.getElementById('bike').alt
);- document.write(" and ");
- document.write(
document.getElementById('car').alt
);- </script></p>
- </body>
- </html>