Jquery check if element exists then add class to different element

Posted by Buddy on Stack Overflow See other posts from Stack Overflow or by Buddy
Published on 2010-04-29T04:23:21Z Indexed on 2010/04/29 4:27 UTC
Read the original article Hit count: 192

Filed under:
|

I don't know much about jquery at all, so bear with my ignorance, but I'm pretty sure I can accomplish this with jquery.

I need jquery to check if an element exists, and if so, add a class to a different element. For example,

if class "minimal-price-link" exists, then add a class to "regular-price" or what I really am wanting to do is make the regular-price strikethrough.

Here's the code:

<div class="price-box">
   <span class="regular-price" id="product-price-2">
       <span class="price">$240.00</span>
   </span>               

   <a href="http://stemulation.com/order/sfs30.html" class="minimal-price-link">
       <span class="label">Your Price:</span>
       <span class="price" id="product-minimal-price-2">$110.00</span>
   </a>
</div>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about JavaScript