I imagine this should be a pretty trivial task but using Firefox for Mac, 3.6.12 the following does not work:
// assign data attributes
$('.gallery li').each(function(i) {
$(this).data('slide',i+1);
});
// outputting an empty jQuery object
console.log($('.gallery li[data-slide]'));
// this does not work either outputting an empty jQuery object
console.log($("[data-slide]"));
using Firebug I can see that all the data-slide attributes including their numerical value are correctly attached to the li
s and logging out:
$('.gallery li').each(function(index) {
console.log($(this).data());
});
outputs as expected:
Object { slide=1}
Object { slide=2}
Object { slide=3}
Object { slide=4}
So why does the first console.log
not work?