Does using custom data attributes produce browser compatibility issues?

╄→гoц情女王★ 提交于 2019-12-04 01:59:24
collapsar

i would advise in favor of data attributes for the following reasons:

  • ids need to be unique document-wide. thus they are limited in the semantics they can carry
  • you can have multiple data-attributes per element

and being probably less relevant in your case:

  • changing ids might break idrefs

(however, i'm not sure whether i understand your specs completely as extracting the element id in jquery is as trivial as getting the data attribute: $('.foo').attr('id');).

you might be interested in this browser compatibility site for web technologies.

if xhtml is an issue to you, you might also be interested in how to use custom data attributes in xhtml: see here for a discussion on SO and here for a xhtml-compatible approach using namespaces.

hope that helps,

best regards, carsten

Tom

this guy says data attibutes work on IE6.

Here is the relevant chart on caniusecom: http://caniuse.com/#feat=dataset

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