使用HTML5的“data - *”时有什么问题吗?旧版浏览器的属性? [英] Is there any problem with using HTML5's "data-*" attributes for older browsers?
问题描述
我想将一些自定义数据与一些HTML节点相关联。我将使用新的HTML5样式的data- *属性。例如:< tr class =foodata-typeid =7> ...
,然后我将选择此HTML节点并显示/隐藏它。通过读取 $(node).attr(data-typeid)
的值。
I want to associate some custom data with some HTML nodes. I was going to use the new HTML5 style 'data-*' attributes. e.g.: <tr class="foo" data-typeid="7">…
, and then I was going to select this HTML node and show/hide it etc. by reading the value with $(node).attr("data-typeid")
.
网页需要使用旧版浏览器。我不是使用data- *属性作为一个特殊的属性,但我想知道,如果旧的浏览器会忽略,擦除或使这个属性无法访问,因为它是无效的HTML4。
However this web page needs to work with older browsers aswell. I'm not using the data-* attribute as a special attribute, but I'd like to know if older browsers will ignore, wipe, or make inaccessible this attribute since it's not valid HTML4.
推荐答案
不是真的,他们不是100%正确/有效的使用在HTML4当然.... 但他们不会导致问题,因此它们仍然是解决我需要一个属性的这个问题的好方法。
There isn't really, they're not 100% correct/valid usage in HTML4 of course....but they don't cause problems either, so they're still a great way to solve the "I need an attribute for this" problem.
如果它有帮助,这些虽然支持IE6和迄今为止零问题,我不记得一个单一的SO问题报告任何一个。
If it helps, I've used these while supporting IE6 and have had zero issues thus far, and I can't recall a single SO question reporting any either.
这篇关于使用HTML5的“data - *”时有什么问题吗?旧版浏览器的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!