This gets the attribute
console.log(doc.find('[data-monitor="total_gross"]').data('amount'));
This should set the attribute, but doesn't
doc.find('[data-monitor="total_gross"]').data('amount', total_gross);
What am I doing wrong?
This gets the attribute
console.log(doc.find('[data-monitor="total_gross"]').data('amount'));
This should set the attribute, but doesn't
doc.find('[data-monitor="total_gross"]').data('amount', total_gross);
What am I doing wrong?
To update in the markup you need to use attr()
method
doc.find('[data-monitor="total_gross"]').attr('data-amount', total_gross);
Refer : jQuery Data vs Attr?