Do HTML5 custom data attributes “work” in IE 6?

后端 未结 6 1874
小鲜肉
小鲜肉 2020-11-22 06:35

Custom data attributes: http://dev.w3.org/html5/spec/Overview.html#embedding-custom-non-visible-data

When I say “work”, I mean, if I’ve got HTML like this:



        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-22 06:57

    You can retrieve values of custom (or your own) attributes using getAttribute. Following your example with

    I can get the value of data-geoff using

    var geoff = document.getElementById("geoff");
    alert(geoff.getAttribute("data-geoff"));
    

    See MSDN. And although it is mentioned there that you need IE7 to get this to work, I tested this a while ago with IE6 and it functioned correctly (even in quirks mode).

    But this has nothing to do with HTML5-specific attributes, of course.

提交回复
热议问题