I want change repeatedly the attribute value of data-number="2"
when .next
is clicked. It works at the first attempt that means the browser gives data-number value as 3. But when I click next times, it doesn't change. It remains 3.
Here my code:
<a class="prev" data-number="1">❮</a>
<a class="next" data-number="2">❯</a>
</div>
<script>
$(document).ready( function(){
$('a.next').on( 'click', function(){
var image_num = parseInt($(this).data('number')) + 1 ;
var num_to_string = image_num.toString();
var prev_value = $(this).attr("data-number", num_to_string );
console.log(prev_value);
} );
} );
</script>
I want to have the value as 3, 4, 5 ....