1) When setting user data (see Live demo) with :
document.getElementById('myelement1').setAttribute('data-size', 20);
I can see this when analyzing the element with the browser's inspector :
<div id="myelement1" data-size="20">Blah</div>
2) When setting user data with jQuery :
$('#myelement2').data('size', 20);
I can see this when analyzing the element with the browser's inspector :
<div id="myelement2">Blah</div>
Why is the element present in the DOM in 1) but not in 2) ?
How does jQuery .data('size', 20)
store the data, and where if it's not in the DOM ?
(I'm not advanced enough in JS to find the exact place in the code that does that)