-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
}
Lux
  • 17,835
  • 5
  • 43
  • 73
this.hart
  • 218
  • 2
  • 9
  • `Javascript 1` ? what is javascript 1? – Jaromanda X Oct 11 '17 at 02: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. – nnnnnn Oct 11 '17 at 03:00
  • Brendan's baby that preceded CSS by over a year ... :p – Jaromanda X Oct 11 '17 at 03:03

1 Answers1

1

Use jQuery css:

 if ($("#lbstatus").text() === "progress")
 {
    $("#lbstatus").css("background-color", "blue");
 }
dhilt
  • 18,707
  • 8
  • 70
  • 85