Anyone know a quick and efficient way to grab all the data attributes from a single element? I realize that jQuerys .data() will do just that, however it will not give me data attributes set using .attr() UNLESS I first select the data attribute using .data(); Also, you can't select elements by data attributes that were added using .data(), which seems silly.
html
<div data-foo="bar"></div>
javascript
$("div").data();
//returns {foo:bar} good :)
$("div").attr("data-hello","world");
$("div").data()
//returns {foo:bar} no good :(
$("div[data-hello]");
//returns the div, all good :)
$("div").data("find","me");
$("div[data-find]");
//returns nothing, very bad
Hopefully this explains