ES5-DOM-SHIM icon indicating copy to clipboard operation
ES5-DOM-SHIM copied to clipboard

fix [set/get/remove]Attribute

Open termi opened this issue 13 years ago • 1 comments

MDSN: getAttribute method setAttribute method removeAttribute method

For resolve problems with properties and attributes in IE < 8, we can use second parameter in [get/remove]Attribute and third parameter in setAttribute.

var div = document.createElement("div");
div.testValue = 666;
div.setAttribute("testValue", "lolcat");
console.log("property value: " + div.testValue, " ", "attribute value: " + div.getAttribute("testValue"));

div.testValue = 666;
div.setAttribute("TESTVALUE", "lolcat", 1);
console.log("property value: " + div.testValue, " ", "attribute value: " + div.getAttribute("TESTVALUE", 1));

termi avatar Aug 20 '12 12:08 termi

for IE8 Element.prototype.[set/get/remove]Attribute

termi avatar Aug 20 '12 14:08 termi