【发布时间】:2015-04-28 16:34:01
【问题描述】:
我的 JavaScript 类中有这个问题:
//===== i set this data record
jQuery(element).data("types", "row");
console.log(jQuery(element).data("types")); // writes "row" (the element is a div)
//==== into other method
//==== i want find all element with data-types = row
console.log(jQuery("[data-types='row']").length); // writes 0
jQuery("div").each(function(i,e){
console.log(i, jQuery(e).data(), jQuery(e).attr("id")); // writes object{type:row}
});
为什么用这个 jQuery("[data-types='row']") 我找不到元素???
【问题讨论】:
标签: javascript jquery jquery-selectors custom-data-attribute