Html:
<meta itemprop="price" content="34,95 € " />
I need to update price dynamically. To get it I use:
$('meta[itemprop="price"]').attr('content');
Which method can be used to replace price?
You can simply give the attr
function a second argument which is the value.
$('meta[itemprop="price"]').attr('content', 'newContent');
//newContent doesn't have to be in quotes, it can be a variable too
Read more about attr
here.
$('meta[itemprop="price"]').attr('content', newValue);
.attr( attributeName )
is a getter
.attr( attributeName, value )
is a setter
You can read more here: http://api.jquery.com/attr/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With