I want to deselect all values with one click without using each id
seperately.
I fiddled around for a while, but this deselect only first value. Any suggestions?
This is how I try to deselect:
$( "#mybutton" ).click(function() {
$("select").select2('val', '')
});
Try this instead:
$('select').select2({
placeholder: "select me"
});
$("#mybutton").click(function () {
$("select").each(function () { //added a each loop here
$(this).select2('val', '')
});
});
Demo here