ÍøÂçѧԺ w3popÉçÇø ÍøÂç×ÊÔ´ ITÐÂÎÅ

w3pop.com :: ÍøÂçѧԺ :: HTML DOM :: HTML DOM idÊôÐÔ

»áÔ±µÇ½

ÕʺÅ

ÃÜÂë

»Ø´ð

¼ÇסÃÜÂë

Íü¼ÇÃÜÂë? ×¢²á

HTML DOM idÊôÐÔ


×÷Õß:w3pop.com ·­Òë/ÕûÀí:w3pop.com ·¢²¼:2007-04-28 ä¯ÀÀ:1406 :: ::

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