自定义数据属性的替代方案? [英] custom data attributes alternative?
问题描述
以下代码处于while循环中,带有数据库中的值.我将这些值存储在jQuery的自定义数据属性中.
The following code is in a while loop, with values from the database. I am storing these values in custom data attributes for jQuery.
<div class='pending-information' data-id='$id' data-pid='$position' data-sid='$sid' data-image='$image' data-counter='$counter' data-start='$start'></div>
什么是专业方法?此方法在XHTML1中无效.那么为jQuery存储属性/值的常用方法是什么?
What is the professional approach? This method won't be valid in XHTML1. So whats the common method for storing attributes/values for jQuery?
推荐答案
什么是专业方法?
What is the professional approach?
您正在做什么- data-*
属性是执行此操作的常用方法.
Exactly what you are doing - data-*
attributes are common way to do this.
此方法在XHTML1中无效
This method won't be valid in XHTML1
那又怎样?XHTML不会扩展到新版本-从现在开始就是HTML 5,而 data-*
属性是必经之路.
So what? XHTML is not going to be extended into a new version - it is HTML 5 from now on and data-*
attributes are the way to go.
这篇关于自定义数据属性的替代方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!