In jQuery, you can set values for an attribute by data
.
So:
$('body').data({id: 1, nome: 'stack'});
And the result would be:
console.log($('body').data()); // {id: 1, nome: 'stack'}
But if I want to rewrite the object, I can not do this with data
.
$('body').data({nome: 'stack'});
console.log($('body').data()); // {id:1, nome: 'stack'}
Note that id
was still there, even though I was resetting the date value.
How can I delete a value of data
or the entire value of data
in jQuery?