Home > DeveloperSection > Forums > Jquery Help needed in changing color in condition
Takeshi Okada
Takeshi Okada

Total Post:89

Points:629
Posted on    May-11-2013 3:16 AM

 JQuery JQuery 
Ratings:


 1 Reply(s)
 928  View(s)
Rate this:
Hi Expert!

I want a jQuery snippet for changing color of a button on condition--> I am using woocommerce with WordPress. What I want is : if there is Cart item is 0 then I want 

to show red color and if any item in cart then the button goes green

Please Help!

Thanks In Advance


AVADHESH PATEL

Total Post:604

Points:4228
Posted on    May-11-2013 9:59 AM

Hi Takeshi!

Put your item number in a div/span and give an id. For example I took 'item_container' is the id of that div then:

$(document).ready(function(){
   var item_nu = $('#item_container').html().parseInt();
    if(item_nu=='0')
     {
       //write your code here to make the button red
     }
    else{
       //write your code here to make the button green
     }
 })

Don't want to miss updates? Please click the below button!

Follow MindStick