Changing CSS based on the value

前端 未结 4 1427
一整个雨季
一整个雨季 2021-01-22 10:58

I have been asked to implement a small validation on values and if the values are greater or less than 0 i need to change or add/remove the css for the td and i tag

My t

4条回答
  •  执笔经年
    2021-01-22 11:25

    var lis=document.querySelectorAll("tr td i");
    for(var i in lis){
        if(parseInt(lis[i].innerHTML)<0){
        lis[i].className+=" fa-level-down";
      }
      else{
            lis[i].className+=" fa-level-up";
      }
    }
    

提交回复
热议问题