You can do this:
$('ul li a').click(function (e) {
e.preventDefault();
var value = $(this).data('value');
$('.button').data('value', value);
console.log($('.button').data('value'));
});
Here, $(this).data('value')
is used to get the data
attribute value of the link.
and $('.button').data('value', value)
is used to set the data
attribute value of the button.
Using, console.log($('.button').data('value'));
you can check the console the data
value being set.
For more info:- .data() API Documentation