jQuery add class to specific div

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

1 Answer

same way as you added class to your span

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like