check for a span class content and then update the quantity using jquery?

Posted by PD24 on Stack Overflow See other posts from Stack Overflow or by PD24
Published on 2011-11-14T09:30:42Z Indexed on 2011/11/14 9:50 UTC
Read the original article Hit count: 181

Filed under:
|

I have code code here:

//Check current
if (parseInt($("#Quantity").val()) < 25) {
// If it is less than 25 then set it to 25
$("#Quantity").attr("value", "25");
} 

It checks if the quantity box has less than 25 and if it is, adds 25 to the box. The problem is on a particular product i need to check IF my pages contains:

<span class="ProductNameText">This is product ABC</span>

This is a work around because the customer only has 2 products which dont require 25 quantity. Ideally i would want to check if a page contained Kit Option form fields and then add 25 to the box.

Any ideas on how to check for a span and then update the quantity. But the quantity shouldnt be forced, so if the user wants 6 items they should be able to add that figure.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery