Hello. I want to replace the value of the 'data-quantity' attribute in the link. How to do it? through val, html, text does not work ..
var number = 3; $('a').attr('data-quantity').val(number);
<a href="#" data-quantity="1">Купить</a>
Hello. I want to replace the value of the 'data-quantity' attribute in the link. How to do it? through val, html, text does not work ..
var number = 3; $('a').attr('data-quantity').val(number);
<a href="#" data-quantity="1">Купить</a>
var number = 3; $('a').data('quantity', number);
Read more here: https://api.jquery.com/data/
It is possible so:
var number = 3; $('a').attr('data-quantity', number);
like this: $('a').data('quantity',number);
Source: https://ru.stackoverflow.com/questions/440272/
All Articles