Is there a way to clear all option and optgroup HTML elements by using jquery?
My HTML select element is like this,
<select id="users" name="multiselect" multiple="multiple" style="width:382px;" >
<optgroup id="groupadmin" label="Group Admin"></optgroup>
<optgroup id="systemusers" label="System User"></optgroup>
</select>
You can use .empty()
Description: Remove all child nodes of the set of matched elements from the DOM.
Code
$('#users').empty()
As you are using multiSelect plugin, You need to use .multiSelect('refresh')
method.
$('#users').empty().multiSelect('refresh');