121
rated 0 times
[
127]
[
6]
/ answers: 1 / hits: 19140
/ 7 Years ago, tue, january 23, 2018, 12:00:00
I am trying to create a reset button for jquery-select2 multiple select. I have no idea why my solution doesn't work.
Html:
<select id=workload-selector class=js-source-states-2 multiple=multiple style=width: 100%>
<option value=haha>haha</option>
<option value=haha2>haha2</option>
<option value=haha3>haha3</option>
</select>
<button id=reset>
Reset
</button>
Javascript:
$(#workload-selector).select2();
$(#reset).click(function(){
$(#workload-selector option:selected).removeAttr(selected);
});
I made it on jsFiddle:
https://jsfiddle.net/DTcHh/41975/
More From » jquery