dojo.NodeList.attr¶
since: | V1.2 |
---|---|
Removed: | in V1.7 |
Contents
A getter and setter for DOM attributes, events and CSS styles adapted to work with node lists.
Introduction¶
NodeList.attr
adapts dojo.attr for use with node lists by applying it to every node in the list.
See dojo.attr for more details.
Usage¶
dojo.query(sel).attr(attr, value);
- attr
- the attribute property name or an object with key/value pairs suitable for setting each property.
- value
- If passed, sets value on the node for an attribute, handling cross-browser concerns.
Examples¶
Setting different node attributes¶
The following example will set several attributes such as the value
and disabled
.
function enable(){
dojo.query("input").attr("disabled", false);
}
function disableAndSet(){
dojo.query("input").attr({
disabled: true,
value: "cool, eh?"
});
}
<p><input name="one"></p>
<p><input name="two"></p>
<p><input name="three"></p>
<p><button onclick="enable();">Enable</button></p>
<p><button onclick="disableAndSet();">Disable & Set</button></p>