jquery - find values in div, compare and color parent container -
i need compare value of .val1 against value .val2. if val1 greater val1 container #benchmark gets background-color red else color green. see done jquery.
    <div id="benchmark"> score team 1<div id="val1">8</div> score team 2<div id="val2">10</div>    </div>      
correct html
    <div id="benchmark"> score team 1<div id="val1">8</div> score team 2<div id="val2">10</div>    </div>   to find value , use
$("#val1").text();   //so code :
var value1=parseint($("#val1").text()); var value2=parseint($("#val2").text());   if(value1>value2) {     $("#benchmark").css('background-color', 'red'); }   else  {      $("#benchmark").css('background-color', 'green'); }        
Comments
Post a Comment