[Solved] jQuery add class to element, if this class is not already there [duplicate]


Just call addClass(). jQuery will do the check for you. If you check on your own, you are doubling the work, since jQuery will still run the check for you.

source:
Check if class already assigned before adding

solved jQuery add class to element, if this class is not already there [duplicate]