jQuery add class to specific div

时间:2015-07-28 16:31:25

标签: jquery

I have a piece of code that is reading how many items are in a shopping basket, I would like to add a class to a div with the id of #basket_count. I know how to add a class to the span tag were the counter is appearing. Not sure how to go from here, any help would be appreciated.

 $('span#ctl00_lblItems').filter(function (index) {
            return parseInt(this.innerHTML) > 0;
        }).addClass("green");

1 个答案:

答案 0 :(得分:1)

same way as you added class to your span

$("#basket_count").addClass("your_class");