---
title: "setting background-color in jQuery?"  
description: "setting background-color in jQuery?"  
author: "Mark Devid"  
published: 2013-04-08  
updated: 2013-04-08  
canonical: https://www.mindstick.com/forum/737/setting-background-color-in-jquery  
category: "jquery"  
tags: ["jquery"]  
reading_time: 1 minute  

---

# setting background-color in jQuery?

Hi Everyone!\
I'm [trying](https://answers.mindstick.com/qa/93698/6-mistakes-couples-are-trying-to-save-money) to make a jQuery that if the [value](https://www.mindstick.com/articles/23219/an-optimized-description-adds-value-to-experience-and-in-turn-effectively-guest-posting-packages) is 130 the [color](https://www.mindstick.com/articles/77/how-to-split-form-background-color-in-c-sharp) of the background.\
Here is my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) so far:\
[function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) Compute(p, m, f, studno) { [var](https://www.mindstick.com/forum/33920/what-is-different-var-and-dynamic-types-in-c-sharp) average; average = parseFloat(p * 0.3) + parseFloat(m * 0.3) + parseFloat(f * 0.4); $("#average_" + studno).val(average.toFixed()); if($(this).text()=="130"){ color:[red](https://yourviews.mindstick.com/view/81343/lonar-lake-turning-red-again) } }\
Thanks in [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)!

## Replies

### Reply by AVADHESH PATEL

Hi Mark!\
This way!\
Use this instead - $(this).css('backgroundColor', 'red');:\

```
function Compute(p, m, f, studno) {     var average;     average = parseFloat(p * 0.3) + parseFloat(m * 0.3) + parseFloat(f * 0.4);     $("#average_" + studno).val(average.toFixed());                                 if($(this).text()=="130"){       $(this).css('backgroundColor', 'red');                }        }
```


---

Original Source: https://www.mindstick.com/forum/737/setting-background-color-in-jquery

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
