Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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);
            };
        });
like image 691
Soheil Alizadeh Avatar asked Jan 05 '17 22:01

Soheil Alizadeh


1 Answers

Posting my comment as answer

Instead try:

$(element).removeClass('form-control-danger');
like image 61
Loaf Avatar answered Nov 02 '22 12:11

Loaf