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

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

Marcus Vance

Marcus Vance

Cybersecurity & Digital Privacy Researcher

Marcus Vance is a cybersecurity auditor and technology writer dedicated to educating the public about online safety, data privacy regulations, enterprise security, and emerging cyber threats.

Share this article
Twitter Facebook Pinterest