javascript - Jquery find class, value and change background color -


so have code

<div class="width100">     <div class="width16 aux"><h1>abc</br>a1</h1><p class="aux-status">50</p></div>     <div class="width16 aux"><h1>abc</br>b2</h1><p class="aux-status">24</p></div>     <div class="width16 aux"><h1>abc</br>c3</h1><p class="aux-status">24</p></div>     <div class="width16 aux"><h1>def</br>1a</h1><p class="aux-status">24</p></div>     <div class="width16 aux "><h1>abc</br>d4</h1><p class="aux-status">0</p></div>      <div class="width32 aux coomms">have: 12213</div>       <div class="width16 aux clear"><h1>abc</br>e5</h1><p class="aux-status">24</p></div>     <div class="width16 aux"><h1>abc</br>f6</h1><p class="aux-status">0</p></div> </div> 

now need loop throughall paragraphs class "aux-status" , check value. if value <10 need change background green, between 10 , 20 orange , above 20 red.

any ideas how that?

$('.aux-status').each(function(index,value){    var value1 = parseint($(this).text(),10);        if(value1  <10)        $(this).css('background-color','green');       else if(value1  > = 10 && value <=20)        $(this).css('background-color','orange');       else         $(this).css('background-color','red');   }); 

http://jsfiddle.net/flsvt/2/


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -