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

前端 未结 2 1901
北恋
北恋 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 18:23

    $(function(){
        $('.subTotalPrice').each(function(){
            if(parseInt($(this).text, 10) > 55){
                $(this).css({'color':'red', 'text-decoration':'underline'});
            }
        });
    });
    

提交回复
热议问题