---
title: "Jquery Help needed in changing color in condition"  
description: "Jquery Help needed in changing color in condition"  
author: "Takeshi Okada"  
published: 2013-05-11  
updated: 2013-05-11  
canonical: https://www.mindstick.com/forum/869/jquery-help-needed-in-changing-color-in-condition  
category: "jquery"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# Jquery Help needed in changing color in condition

Hi [Expert](https://www.mindstick.com/articles/13120/an-expert-financial-advice-will-improve-your-finances)!\
I want a jQuery snippet for changing [color](https://www.mindstick.com/articles/77/how-to-split-form-background-color-in-c-sharp) of a [button](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) on [condition](https://www.mindstick.com/forum/12711/select-query-with-and-condition)--> I am using woocommerce with WordPress. What I want is : if there is Cart [item](https://www.mindstick.com/forum/156564/remove-item-in-an-array-in-javascript) is 0 then I want \
to show [red](https://yourviews.mindstick.com/view/81343/lonar-lake-turning-red-again) color and if any item in cart then the button goes [green](https://www.mindstick.com/articles/95829/think-green-sustainable-design-considerations-for-commercial-buildings)\
Please Help!\
Thanks In [Advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)

## Replies

### Reply by AVADHESH PATEL

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 } })


---

Original Source: https://www.mindstick.com/forum/869/jquery-help-needed-in-changing-color-in-condition

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
