I have a form with a couple of fields, one of then is a select with 4 options, I've a reset link to clear all fields, it works, except for the select.
I've tried a couple of options and no seems to work. Here are what I've tried without success.
$("input[name='gender']").find('option:selected').remove();
This
$('#gender').find('option:selected').removeAttr('selected"');
This
document.getElementById('gender').selectedIndex = -1;
I want to remove all attributes selected
of option, or select the first option could be a default value.
So far I've this code to clean all inputs, I've tried the button type reset, but since I have some data returning from server, field masks and field validations running in this form I'm only able to proper empty field setting empty values to it.
$('#reset_form_link').click(function() {
$(':input','#client_form')
.not(":button, :submit, :reset, :hidden[name='_token'], :hidden[name='_method']")
.val('')
.removeAttr('checked')
.removeAttr('selected');
});