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'); });
Comments
Post a Comment