I want to update the value of data attribute. I checked showing alert message but when I inspect element the value is not updated. Here is my code:
alert(pid); // show 1
alert($('#buybtn').data('id')); // show 'hello'
$('#buybtn').data('id',pid);
alert($('#buybtn').data('id')); // show 1
But after this code run I checked the data attribute value. It shows previous data as follows:
What is the wrong in my code? Thanks for your time.