XUL:Attribute:id
From MDC
- id
- Type: element id, must be unique in the window
- A unique identifier so that you can identify the element with. You can use this as a parameter to
getElementById()and other DOM functions and to reference the element in style sheets.
[edit] Example
<button id="foo" label="Click Me" oncommand="doSomething()"/>
<script>
function doSomething(){
var myButton = document.getElementById('foo');
myButton.setAttribute('label','The button was pressed');
}
</script>
A more abstract version of the above would be a
<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>