Is it possible to read the price using javascript
<span id="product_price_00873"> <span itemprop="price">178.00</span> </span>
I just want to pay 178.00. I can only use javascript.
Any suggestions would be appreciated.
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; break; } }
http://jsbin.com/atimux/edit#javascript,html,live
If you have a product item in product , and you are using a modern browser, this should work:
product
var price = product.querySelector('[itemprop=price]').textContent;