When i edit a DOM element with jQuery.data
function, DOM code is not really updated:
Ex, for:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<div id="foo" data-price="100">Foo</div>
</body>
</html>
And:
console.log($('#foo').data('price'));
$('#foo').data('price', 90);
console.log($('#foo').data('price'));
console.log('[data-price=90]: ' + $('[data-price=90]').length);
console.log('[data-price=100]: ' + $('[data-price=100]').length);
Output is:
100
90
"[data-price=90]: 0"
"[data-price=100]: 1"
(This exemple is available here)
So, after jQuery.data
usage, div#foo
still have 90 as price. How to really modify it with jQuery method ?