w3pop.com :: ÍøÂçѧԺ :: HTML DOM :: HTML DOM idÊôÐÔ
The id property sets or returns the id of the body.
idÊôÐÔ¿ÉÉèÖûò·µ»ØbodyµÄid
bodyObject.id=id |
The following example shows two methods on how to get the id of the <body> element:
ÈçºÎʹÓÃÁ½ÖÖ·½·¨À´µÃµ½<body>ÔªËØµÄid
<html>
<body id="myid">
<script type="text/javascript">
x=document.getElementsByTagName('body')[0];
document.write("Body id: " + x.id);
document.write("<br />");
document.write("An alternate way: ");
document.write(document.getElementById('myid').id);
</script>
</body>
</html>
|
Output:
Êä³ö
Body id: myid An alternate way: myid |
Return the id of the <body> element
·µ»Ø<body>ÔªËØµÄid
ÆÀÂÛ (0)
All