We can easily change the css class of an element using javascript. I am not sure that what do you mean by "change the css class of finction ".
You can change the css class of any element as
To replace all existing classes with one or more new classes, set the className attribute:
document.getElementById("MyElement").className = "MyClass";
To add an additional class to an element:
To add a class to an element, without removing/affecting existing values, append a space and the new classname, like so:
document.getElementById("MyElement").className += " MyClass";
Let me know if this resolves your problem