最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery.data() and cross browser compatibility? - Stack Overflow

programmeradmin4浏览0评论

I want to use the jQuery.data() method to attach data to a DOM object as an alternative to storing it in an attribute.

The method seems perfectly suited to my needs, but in the jQuery docs (.data/), there's this line:

Note that this method currently does not provide cross-platform support for setting data on XML documents, as Internet Explorer does not allow data to be attached via expando properties.

Does this mean the method won't work in IE? In my testing the method works fine with IE8 on Windows 7, but I don't want to run into issues with any browsers.

Thanks.

I want to use the jQuery.data() method to attach data to a DOM object as an alternative to storing it in an attribute.

The method seems perfectly suited to my needs, but in the jQuery docs (http://api.jquery./jQuery.data/), there's this line:

Note that this method currently does not provide cross-platform support for setting data on XML documents, as Internet Explorer does not allow data to be attached via expando properties.

Does this mean the method won't work in IE? In my testing the method works fine with IE8 on Windows 7, but I don't want to run into issues with any browsers.

Thanks.

Share Improve this question asked Jan 31, 2011 at 19:13 GiorgioGiorgio 4795 silver badges7 bronze badges 1
  • 2 they are referring to XML docs, if you are not planning to use it on XML docs you are fine – Kris Ivanov Commented Jan 31, 2011 at 19:16
Add a ment  | 

1 Answer 1

Reset to default 15

Notice the

... for setting data on XML documents ...

As long as you're working with HTML I think you should be fine

发布评论

评论列表(0)

  1. 暂无评论