Is there a way to add a custom HTML attribute to say a DIV element and then be able to use CSS attribute selectors with it in IE?
Example that works (turns into green) in FF but not in IE:
in JavaScript:
element.setAttribute('newAttr', 'green');
in CSS:
[newAttr=green] {
background-color: green;
}
Kind regards
您可以这样做:
<div id="some" data-newattr="green"></div>
var attribute = document.createAttribute("size");
attribute.nodeValue = "15"
document.getElementById("text").setAttributeNode(attribute);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.