javascript - How to change the color of the number if the value decrease or increase? -
i alter number color reddish if value less -15 or need alter color greenish if value + 15
ad please allow me know if can alter color inbetween , >15 , <20
can that?
thanks
just add together class depending on score
demohtml:
<table> <tr> <th>#</th> <th id="positive">positive</th> <th>negative</th> <th>avg. rating</th> </tr> <tr> <td>12</td> <td>8</td> <td>4</td> <td>4</td> </tr> <tr> <td>12</td> <td>8</td> <td>4</td> <td>4</td> </tr> <tr> <td>12</td> <td>8</td> <td>4</td> <td>4</td> </tr> <tr> <td>12</td> <td>8</td> <td>4</td> <td>4</td> </tr> <tr> <td>20</td> <td id="positivescore">13</td> <td>22</td> <td>4.5</td> </tr> </table> css:
.red { color: red; } .green { color: green; } .blue { color: blue; } jquery:
$("#positive").addclass((parseint($("#positivescore").text()) >= 15) ? 'green' : (parseint($("#positivescore").text()) <= -15) ? 'red' : 'blue'); javascript jquery
No comments:
Post a Comment