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 8159387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:53:38+00:00 2026-06-06T17:53:38+00:00

Spent a good few hours on this now and don’t seem to be getting

  • 0

Spent a good few hours on this now and don’t seem to be getting anywhere!

I have 5 related products at the bottom of the page. Currently there is a “was” price showing on these products regardless of if they are discounted. Located above is the actual price, obviously if the product isn’t discounted the prices appear will the same, which is not cool.

So I’ve written a script that checks if the “actual” price is the same as the “was” price, if true it simply removes the “was” Div element. Works fine.

Now the issue I have is making this rule work for multiple elements with he same class in a page. For some reason when I try to pass a variable within an “.each” function, it returns a string which contains all of the Div values for every “.each” element, as oppose to just returning the value for its relative parent element. e.g. “£674£1999.99£674” rather than “£674”.

Checks to see if actual price is the same as was price:

    $('.floatleft').each(function() {
    var wasprice = $('.was').text();
    var ourprice = $('.now').text();

    if (wasprice == ourprice) {

    $('div.price-extras').remove();
    $('.productdetails-view .product-price .PricesalesPrice').css('line-height','40px');

};
});

Sample of the HTML code:

<div class="vmproduct-featured">
  <div class=" width20 floatleft">
    <div class="spacer">
      <a href="/store/powertools/tacx-i-magic-t1900-trainer-info" title="Tacx I-Magic T1900 Trainer" class="img-link">
        <img src="/store/product/resized/123_150x150.jpg" alt="123" class="featuredProductImage" border="0">
      </a>
      <div class="clear"></div>     
      <a class="text-link" href="/store/powertools/tacx-i-magic-t1900-trainer-info">Tacx I-Magic T1900 Trainer</a>      
      <div class="clear"></div>
      <div class="was">£674.00</div>
      <div class="now">£674.00</div> 
    </div>
  </div>
  <div class=" width20 floatleft">
    <div class="spacer">
      <a href="/store/powertools/2012-cube-agree-gtc-di2-info" title="2012 Cube Agree GTC DI2" class="img-link">
        <img src="/store/product/resized/12cubeagreegtcdi2_150x150.jpg" alt="12cubeagreegtcdi2" class="featuredProductImage" border="0">
      </a>
      <div class="clear"></div>     
      <a class="text-link" href="/store/powertools/2012-cube-agree-gtc-di2-info">2012 Cube Agree GTC DI2
      </a>      
      <div class="clear"></div>
      <div class="was">£1,999.99</div>
      <div class="now">£2,499.99</div> 
    </div>
  </div>
 </div>

So basically I’m failing at the .each() and need some assistance, please <3

  • 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-06T17:53:40+00:00Added an answer on June 6, 2026 at 5:53 pm

    that’s because $('.was').text(); selects all the texts of the was class at once, try this:

    $('.was').each(function() {
        var wasprice = $(this).text();
        var ourprice = $(this).siblings('.now').text(); // or "$(this).next('.now').text();"
    
        if (wasprice == ourprice) { 
            $('div.price-extras').remove();
            $('.productdetails-view .product-price .PricesalesPrice').css('line-height','40px');
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've spent a good few hours googling for something to allow me to open
First, forgive me if this has been answered already. I spent a few hours
I have spent a good few days learning linq and producing json results from
I've spent a good while getting my AVR development system set up with the
Spent the good part of this morning working through this, but still…. apologies if
Facebook Connect I have spent a few weeks putting together a basic web site
A few weeks ago, I have read this thread Is < faster than <=?
I spent a good deal of time looking through StackOverflow, as well as Google,
I've spent a good part of the day trying to figure out why a
I've spent a good portion of my day fighting with GridView.Sort(). Nothing I did

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.