aboutsummaryrefslogtreecommitdiff
path: root/files/pl/mozilla/tech/xul/atrybut/id/index.html
blob: f9fc9f811da902bb529388bbd378f676fbc093d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
---
title: id
slug: Mozilla/Tech/XUL/Atrybut/id
tags:
  - Atrybuty_XUL
  - Dokumentacja_XUL
translation_of: Archive/Mozilla/XUL/Attribute/id
---
<div class="noinclude"><span class="breadcrumbs xulRefAttr_breadcrumbs">« <a href="/pl/docs/Dokumentacja_XUL">Dokumentacja XUL</a></span></div>
<dl><dt> <code id="a-id"><a href="https://developer.mozilla.org/pl/docs/Mozilla/Tech/XUL/Atrybut/id">id</a></code>
</dt><dd> Typ: <i>id elementu, musi być unikatowym identyfikatorem w oknie</i>
</dd><dd> Unikatowy identyfikator, który będzie identyfikował się z elementem. Możemy go zastosować jako parametr do <code><a href="pl/DOM/document.getElementById">getElementById()</a></code> i innych funkcji DOM oraz jako odniesienie do elementu w arkuszach stylu. </dd></dl>
<div class="noinclude">
<h4 id="Przyk.C5.82ad" name="Przyk.C5.82ad">Przykład</h4>
<pre>&lt;button id="foo" label="Click Me" oncommand="doSomething()"/&gt;

&lt;script&gt;
function doSomething(){
    var myButton = document.getElementById('foo');
    myButton.setAttribute('label','The button was pressed');
}
&lt;/script&gt;
</pre>
<p>Więcej abstrakcyjnych wersji powyższego przykładu będzie:
</p>
<pre>&lt;button id="foo" label="Click Me" oncommand="setWidgetLabel(this, 'I was pressed')"/&gt;
&lt;script&gt;
function setWidgetLabel(idName, newCaption){
   document.getElementById( idName.id ).setAttribute('label',newCaption)
}

&lt;/script&gt;
</pre>
<h4 id="Zobacz_tak.C5.BCe" name="Zobacz_tak.C5.BCe">Zobacz także</h4>
<p><code><code id="a-name"><a href="https://developer.mozilla.org/pl/docs/Mozilla/Tech/XUL/Atrybut/name">name</a></code></code>
</p>
</div>