2
我想创建一个jQuery搜索会发现,刚刚有一个数据属性改变元素的元素。搜索不起作用。这里是JavaScript(由CoffeeScript的编译):jQuery选择找到基于数据属性不工作
new_temp_value = "" + (Math.round((new Date()).getTime()/1000));
console.log("new_temp_value is " + new_temp_value);
$activity_div.data('temp', new_temp_value);
console.log('value of data-temp in $activity_div is now');
console.log($activity_div.data('temp'));
console.log($activity_div.hasClass('activity_div'));
console.log($(".activity_div[data-temp='" + new_temp_value + "']"));
输出
new_temp_value is 1336020404
value of data-temp in $activity_div is now
1336020404
true
[]
到底哪里出问题了?
恕我直言,当你操纵数据,新的数据值不会写在html..so当您尝试查找基于新的数据值的DOM,它没有发现 – bondythegreat
什么'$ activity_div的声明“看起来像? –
等待...你可以使用** **数据作为一个选择? – McGarnagle