当前位置: 首页 > 网络学院 > 客户端脚本教程 > HTML DOM > HTML DOM id属性

HTML DOM
DOM TableRow 对象
DOM Textarea 对象
DOM Window 对象

HTML DOM id属性


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 367 ::
收藏到网摘: n/a

Definition and Usage
定义与用法

The id property sets or returns the id of an image.
id属性可用来返回或设置图片的id

Syntax
语法

imageObject.id=id


Example
举例

The following example returns the id of an image in two different ways:
下面的举例将用两种不同的方式来将图片的id返回出来:

<html>

<body>
<img id="compman" src="compman.gif" alt="Computerman" />
<br />
<script type="text/javascript">

x=document.getElementsByTagName('img')[0];
document.write("Image id: " + x.id);
document.write("<br />");
document.write("An alternate way: ");
document.write(document.getElementById('compman').id);
</script>
</body>
</html>


Try-It-Yourself Demos
尝试与演示

Get the id of an image
得到图片的id

评论 (0) All

登陆 | 还没注册?