Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8693691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:36:09+00:00 2026-06-13T00:36:09+00:00

To begin with, I have some experience with JavaScript but mostly with client side

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:36:10+00:00Added an answer on June 13, 2026 at 12:36 am

    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.

    var priceDivs   = document.querySelectorAll ("div.detailPrice");
    for (var J = priceDivs.length - 1;  J >= 0;  --J) {
        var oldPriceParts   = priceDivs[J].textContent.match (/^(?:\s|\D)*([0-9\.,]*)(\d{2})\D*$/);
        if (oldPriceParts.length === 3) {
            var newPrice    = parseInt ('0' + oldPriceParts[1].replace (/[\.,]/g, ""), 10)
                            + parseInt (oldPriceParts[2], 10) / 100
                            ;
            // DO WHATEVER MANIP YOU WANT HERE.
            newPrice        = newPrice * 1.3;
    
            priceDivs[J].textContent = '€ ' + newPrice.toFixed (2).toLocaleString ();
        }
        else {
            console.log ("**Unexpected price format!** ", priceDivs[J]);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some experience with XSLT but now i've got myself a problem: I
I am a web-developer working in PHP. I have some limited experience with using
I have the following line between my \maketitle and my \begin{abstract}: \center{ \textsc{Some text
I have multiple levels of the following: IF EXISTS(...) BEGIN IF NOT EXISTS(...) BEGIN
Let me begin this topic by explaining my background experience with web design. I
This may seem simple to some but I am less experienced with JavaScript. I
So I have some experience with Microsoft Access, building database apps for people, vba,
I have been researching around trying to find the best way to begin developing
I have to correct some C++/STL code. Unfortunately I have very little C++ experience
I don't have much experience with Qt but somehow I think this is acting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.