Not really sure what is the error. I take “not working” as “class is not displaying when it should do”. Any chance you could supply a code or something? Maybe a link to your website?
Please be aware this is not adding a class to the sidebar, but to inserted widget’s wrapper.