Question

There is a div with an attribute data-value = "10".

Does there is anyway to get and update the data-value value?

Answer

1
<div id="mydiv" data-value="10"></div>
1
2
3
var a = $('#mydiv').data('myval'); //getter

$('#mydiv').data('myval',20); //setter

Live Demo

Reference


This is the end of post