I have a list box which I want to clear by jQuery without page refresh.
<asp:ListBox ID="lbComplaints" runat="server"
ClientIDMode="Static" SelectionMode="Multiple"
placeholder="Select Complaints" Style="width: 280px;" AppendDataBoundItems="True">
in a button click
$('input[type="submit"]').click(function (e) {
e.preventDefault();
$("#lbComplaints").val([]);
)};
It does not show any error but the items remain in previous selection.
I tried
$("#lbComplaints").empty();
but all the data of the Listbox is removed but I do not want to remove options but unselection of previous option in Listbox value so that user can select again. How can I do that?
By the way i used
$('#lbComplaints').select2({
placeholder: 'select a state',
//tags: "true",
//allowClear: true,
theme: "classic"
});