![]() | 1 cynial 2011-08-28 12:45:52 +08:00 为什么不直接用id属性呢 |
![]() | 2 Hyperion 2011-08-28 12:52:25 +08:00 加 data-article_id , HTML5里可以这么干... http://www.w3.org/TR/html5/elements.html#embedding-custom-non-visible-data-with-the-data-attributes xhtml, 我估计会通不过严格检查吧... |
![]() | 3 raptium 2011-08-28 12:53:06 +08:00 |
![]() | 4 raptium 2011-08-28 12:53:31 +08:00 啊呀 发慢了…… 还不能删除 ~~ |
![]() | &nsp; 6 chloerei 2011-08-28 12:55:02 +08:00 via Android xhtml已死,不用考虑 不考虑老浏览器的话用data- |
![]() | 7 orzzzzz 2011-08-28 13:01:48 +08:00 自定义属性是可以用的..... |
![]() | 8 chuck911 2011-08-28 13:09:42 +08:00 1. XHTML, with a specific namespace http://www.bennadel.com/blog/1453-Using-jQuery-With-Custom-XHTML-Attributes-And-Namespaces-To-Store-Data.htm <html ... xmlns:xyz="http://www.yourdomain.com"> ... <a xyz:article_id="11">... 2. $.data() The jQuery.data() method allows us to attach data of any type to DOM elements 3. Custom DTD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" [ <!ATTLIST a article_id CDATA #IMPLIED> ]> 4. html5 data-* <a data-article_id="55" class="xxx">1234567</a> |
![]() | 9 darasion OP hi all, 当然要考虑通用了. html5虽然很好, 但是用户不用它也白搭呀. |
![]() | 12 chuck911 2011-08-28 13:15:12 +08:00 我觉得XHTML自定义namespace的方案比较方便且通用 jQuery.data()在你这个情况可能不方便了,article_id是服务端生成的吧 |
![]() | 13 loading 2011-08-28 13:15:23 +08:00 建议通过 href 来操作。 <a href="#mark1" >xxxx</a> <a href="#mark2" >xxxx</a> 或者通过 class,class="xxx mark1 mark2 ..." |
![]() | 15 loading 2011-08-28 14:00:24 +08:00 @darasion 我不知道你用来做什么,如果只是要个标记,开关什么的,这样较为简单。 如果是较多的数据,直接ajax就好了。json很方便的。放那么多不是给用户看的控制数据到html干什么 |
![]() | 16 chloerei 2011-08-28 15:05:59 +08:00 http://caniuse.com/#feat=dataset Note: All browsers can already use data-* attributes and access them using getAttribute. "Supported" refers to accessing the values using the dataset property. |