--- title: id slug: Mozilla/Tech/XUL/Atrybut/id tags: - Atrybuty_XUL - Dokumentacja_XUL translation_of: Archive/Mozilla/XUL/Attribute/id ---
id
getElementById() i innych funkcji DOM oraz jako odniesienie do elementu w arkuszach stylu. <button id="foo" label="Click Me" oncommand="doSomething()"/>
<script>
function doSomething(){
var myButton = document.getElementById('foo');
myButton.setAttribute('label','The button was pressed');
}
</script>
Więcej abstrakcyjnych wersji powyższego przykładu będzie:
<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>