Here is my code:
$(function(){
$("div").data({"one": 1, "two":2});
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div>what ever</div>
After executing the code, I expect to see these two attributes to the element:
<div data-one="1" data-two="2">what ever</div>
But I don't see any:
Well why .data
doesn't add those attributes? And how can I do that?