dojo.removeAttr¶
since: | V1.2 |
---|
Contents
Removes an attribute.
Introduction¶
dojo.removeAttr()
removes an attribute. It is modeled after DOM’s removeAttribute, but unlike the latter it normalizes standard attribute names to smooth over differences between browsers, or to provide convenient aliases, e.g., className
is aliased to class
, and so on. The same algorithm is used by dojo.attr.
Since Dojo 1.7, dojo.removeAttr
is exposed via the remove
method of the dojo/dom-attr
module. An alias is kept in dojo/_base/html
for backward-compatibility.
Usage¶
// Dojo 1.7+ (AMD)
require(["dojo/dom-attr"], function(domAttr){
domAttr.remove(node, attr);
});
// Dojo < 1.7
dojo.removeAttr(node, attr);
- node
- id or reference of the DOM node to get/set style for
- attr
- the attribute property name.
Examples¶
Dojo 1.7+ (AMD)¶
When using AMD format in a fully baseless application, remove
is accessed from the dojo/dom-attr
module.
require(["dojo/dom-attr"], function(domAttr){
domAttr.remove("model", "disabled");
});
Alternatively, you can load dojo base in AMD style and continue using dojo.removeAttr
in the define
or require
callback:
require(["dojo"], function(dojo){
dojo.removeAttr("model", "disabled");
});
Dojo < 1.7¶
dojo.removeAttr("model", "disabled");
Removing an attribute¶
The following example will remove disabled
from the input
node.
function remAttr(){
dojo.removeAttr("model", "disabled");
}
<p><input id="model" name="model" disabled="disabled" value="some text"> — our model node</p>
<p><button onclick="remAttr();">Remove "disabled"</button></p>