Does IE7 support HTML5 data tag?

北慕城南 提交于 2019-12-10 20:08:21

问题


I'm willing to use data tag as below.

<div data-color="#1337c"></div>

I use jquery to fetch($("div").data("color");) and store($("div").data("color", "red");) as well as manipulate data.

  • Will IE7 support above tag ?
  • What is the browser requirement for HTML5 ?

Thanks


回答1:


To answer the real question: jQuery.data works as expected in IE7 .. and IE6. (No HTML5 or official "data attribute" support required.)

IE7 will happily keep any attribute supplied in the HTML and expose it as such in the DOM. It doesn't matter if it is called data-foo or foo-data. I believe this is technically against the HTML4 specification, but it is the behavior of every major browser I know.

Do be aware, however, that data("foo") and attr("data-foo") have different semantics.




回答2:


To my understanding, data attributes are not actually HTML5 features, but rather their use became standardized in HTML5. IE 5.5 (from what I remember) was actually the first browser to support pseudo attributes, but don't quote me on that :v



来源:https://stackoverflow.com/questions/12576592/does-ie7-support-html5-data-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!