Recently I was coding away, and I ran into a weird issue. I was attempting to assign a data attribute to a new element I had created (via jQuery), only to discover it wouldn't actually assign the attribute. See the link below for an example, the code is listed below:
http://jsfiddle.net/y95p100c/1/
Any idea why this is happening? I've never stumbled into this...
var div = $("<div />")
$(div).data("foo", "bar")
console.log($(div)[0].outerHTML) // prints <div></div>
.data()
function stores values internally. – Expectancy