javascriptjqueryfunctionremoveclass

Uncaught TypeError: element.removeClass is not a function In Jquery


I Using This Sample For Validate My form, But Got this Error:

Uncaught TypeError: element.removeClass is not a function says removeClass() Is Not Function !! I'm confused

My Js Code :

$(function () {
            var form = $('#CompanyStep')
              , formData = $.data(form[0])
              , settings = formData.validator.settings
              , oldErrorPlacement = settings.errorPlacement
              , oldSuccess = settings.success;

            settings.errorPlacement = function (label, element) {

                debugger;
                oldErrorPlacement(label, element);

                label.parents('.form-group').addClass('has-danger');
                label.addClass('text-danger');
                element.addClass('form-control-danger');
            };

            settings.success = function (label, element) {

                debugger;

                label.parents('.form-group').removeClass('has-danger');
                label.parents('.form-group').addClass('has-success');
                element.removeClass('form-control-danger');
                element.addClass('form-control-success');


                oldSuccess(label, element);
            };
        });

Solution

  • Posting my comment as answer

    Instead try:

    $(element).removeClass('form-control-danger');