JQuery: If a custom class contains a number greater than 'x' add CSS code

前端 未结 2 1902
北恋
北恋 2021-01-26 17:51

I would like to add css to a assigned span class if it contains a number higher than 55, also this must on a page load and not a button trigger.

Thanks any help would b

2条回答
  •  暖寄归人
    2021-01-26 17:58

    Here's a good way of doing that using jQuery's filter():

    $('.subTotalPrice').filter(function(index){
        return parseInt(this.innerHTML) > 55;
    }).css({'color':'red', 'text-decoration':'underline'});
    

提交回复
热议问题