Can I change the background if a field result is great or equal to another field?

后端 未结 3 505

I am displaying mySQL in an html table.

I would like to change the TD background color of $qty to red IF $qty >= $max or $qty =< $min.

I

3条回答
  •  被撕碎了的回忆
    2021-01-15 06:46

    var min = $('table tr td:eq(0)').text();
    var max = $('table tr td:eq(1)').text();
    var qty = $('table tr td:eq(2)').text();
    
    if (qty >= max || qty <= min ) {
       $('table tr td:eq(2)').css('background-color', 'red');
    }
    

    http://jsfiddle.net/7vUFS/3/

提交回复
热议问题