Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

id

id
类型: 元素的ID,在主窗口中必须唯一
一个唯一的标识一边开发者能够定义. 你可以使用方法 getElementById() 或者其他 DOM 的函数并在样式表中添加对元素的引用。

示例

<button id="foo" label="Click Me" oncommand="doSomething()"/>

<script>
function doSomething(){
    var myButton = document.getElementById('foo');
    myButton.setAttribute('label','The button was pressed');
}
</script>

一个更加抽象的版本

<button id="foo" label="Click Me" oncommand="setWidgetLabel(this, 'I was pressed')"/>
<script>
function setWidgetLabel(idName, newCaption){
   document.getElementById( idName.id ).setAttribute('label',newCaption)
}

</script>

同样,这里还有一些资料

name

文档标签和贡献者

标签: 
 此页面的贡献者: ziyunfei, soundbbg, Gamlty
 最后编辑者: ziyunfei,