-1

How change background color with conditionally.

HTML:

<label class="control-label bold" id="lbstatus"></label>

JS:

if ($("#lbstatus").text() == "progress")
{
  //background color label change
}
3
  • Javascript 1 ? what is javascript 1? Commented Oct 11, 2017 at 2:57
  • See the linked duplicates (or the many other similar questions). Consider using JS to add a class to the element rather than directly changing its background colour, then specify the colour in your stylesheet. @JaromandaX - You know, from back in 1996. Commented Oct 11, 2017 at 3:00
  • Brendan's baby that preceded CSS by over a year ... :p Commented Oct 11, 2017 at 3:03

1 Answer 1

1

Use jQuery css:

 if ($("#lbstatus").text() === "progress")
 {
    $("#lbstatus").css("background-color", "blue");
 }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.