Search code examples
jqueryclassremoveclass

removeClass Error. <Nodelist> has no method removeClass


Object # has no method 'removeClass' I always get this error.

defaultcolor = document.getElementsByClassName('default');
defaultcolor.removeClass("default");`

Solution

  • removeClass is a jQuery Method, if you don't have jQuery in your webpage, it will not work because you get an html object, not a jQuery object.

    If you already have included jQuery, get the element like this:

     $('.default').removeClass('default'); 
    

    It will work.