Is there a way to change the value of an html variable using jquery.
For instance,
<div id="smile" data-count="2"></div>
how would I change the variable data-count to 3 using jquery
Is there a way to change the value of an html variable using jquery.
For instance,
<div id="smile" data-count="2"></div>
how would I change the variable data-count to 3 using jquery
You can do:
$('#smile').data('count', 3);
or:
$('#smile').attr('data-count', 3);
You can store the data
value in a variable and then increase it like this:
var data = parseInt($('#smile').attr('data-count'), 10);
$('#smile').attr('data-count', data+1);