Just so you know, jquery will perform operations on an entire set, so you don't need to do an operation on each individual item. `$('.field_with_errors').parent().removeClass('required').addClass('has-error')` would probably have the same result.