哪些浏览器(和版本)不支持自定义属性?
我想为我的标签添加一些自定义属性,我想知道哪些浏览器不能正确处理它。
HTML:
<div id="mydiv" mycustomattribute="I've got one.">Test</div>
JavaScript:
alert(document.getElementById("mydiv").getAttribute("mycustomattribute"));
最佳答案
首先,使用 data-*
for custom attributes .这将与 HTML5 兼容。其次,all browsers currently support it在使用 getAttribute()
关于javascript - 自定义 HTML 属性的浏览器版本底限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8978569/