Jquery Help needed in changing color in condition

Total Post:89

Points:629

JQuery 
 1614  View(s)
Ratings:
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
  1. Re: Jquery Help needed in changing color in condition

    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
         }
     })

Answer

Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.