I have a script to clear all fields but won’t remove all the style attributes. How can I remove all the style attributes in the form?
Here is my code:
function clear_form_elements(ele) {
$(ele).find(':input').each(function() {
switch(this.type) {
case 'password':
case 'select-multiple':
case 'select-one':
case 'text':
case 'textarea':
$(this).val('');
break;
case 'checkbox':
case 'radio':
this.checked = false;
}
});
}
try this
In general you can remove an attribute in a html tag using the jQuery’s removeAttr(“your attribute name”)…here is more info about removeAttr() JQuery’s removeAttr()