Using javascript to read value from itemprop

Is it possible to read the price using javascript

<span id="product_price_00873">
<span itemprop="price">178.00</span>


I just want to pay 178.00. I can only use javascript.

Any suggestions would be appreciated.


source to share

2 answers

var els = document.getElementsByTagName('span'), i = 0, price;

for(i; i < els.length; i++) {
    prop = els[i].getAttribute('itemprop');

    if(prop) {
        price = els[i].innerHTML;




If you have a product item in product

, and you are using a modern browser, this should work:

var price = product.querySelector('[itemprop=price]').textContent;




All Articles