please advise how to improve this jQuery script:
jQuery(function($) {
$('.qty').on('input change', function() {
$('#ajaxadd').attr( 'data-quantity', $( this ).val() ); });
});
This script adds the number of items to the "data-quantity" field:
<button id="ajaxadd" data-quantity="">Add to cart</button>
I need:
<button id="ajaxadd-2" data-quantity="">Add to cart</button>
<button id="ajaxadd-3" data-quantity="">Add to cart</button>
The problem is that the script is executed only for the first item on the list. For other products does not work, I need a unique ID for each product.