To begin with, I have some experience with JavaScript but mostly with client side scripting of programs and not JavaScript in a Web envoirement.
What I’m trying to do is to fetch and replace the vlaue in this class:
<div class="detailPrice" style="float:left;width:180px"> € 20,90* </div>
The value changes on every page. So I can’t search for this specific value.
When I got the value I want to assign it to a variable like
price = 20.9
do some math to it and then replace my new value with the old one.
Thanks for any sort of help in advance.
Use
querySelectorAll()to get the div(s) and use regex to extract the price if you are fairly sure of the format.The regex, below accounts for common European and USA formats, but assumes two digits to the right of the decimal point.
See the code in action at jsFiddle.