jquery set data attr

jquery

Solution

attr() And you can not have to change the data() method.

Try the following way:

console.log($("#you").data("you")); // Hello mean

$("#you").data("you", "yes change you atribute"); // yes change you atribute

console.log($("#you").data("you")); //  yes change you atribute

examples of data http://api.jquery.com/data/​​​​​​

Problem

Html ``` <div id="you" data-you="Hello mean">super</div> ``` is #you html element change data-you attribute ``` console.log($("#you").data("you")); // Hello mean $("#you").attr("data-you", "yes change you atribute"); console.log($("#you").data("you")); // Hello mean | does not change. ``` Attribute "data-you" does not change when I change. How can I do this? thank you.

Original source