JQuery find between two text values -


i running code jquery script, method can detect values higher or lower not between them.

for example: first statement says lower 1.

how change , make between 0-1.

second statement between 1-29...

third statement 29-49 , on...

the code works fine, need between, because statement higher value overwrite others... thoughts ?

$(document).ready(function(){         $('.table td').each(function(){             if($(this).text() <1) {                 $(this).css('background-color','#fff');             }             else if($(this).text() <29) {                 $(this).css('background-color','#9a271c');             }             else if($(this).text() <49) {                 $(this).css('background-color','#ba650e');             }         });     }); 

you need use && , while use .text() think need parseint(); well

$(document).ready(function(){         $('.table td').each(function(){             var thisnumber = parseint($(this).text());             if( thisnumber  < 1) {                           // less 1                 $(this).css('background-color','#fff');             }             else if( thisnumber  >= 1 && thisnumber <29) {   //between 1 - 29                 $(this).css('background-color','#9a271c');             }             else if( thisnumber >= 29 && thisnumber <49) {   // between 29-49                 $(this).css('background-color','#ba650e');             }         });     }); 

Comments