Created
October 28, 2015 21:12
-
-
Save lyonsun/8ed7d542f7ccd69312cd to your computer and use it in GitHub Desktop.
add a checkbox input and use this code to select or unselect all.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// credits: http://jsfiddle.net/jeadr/62/ | |
$("#e1").select2(); | |
$("#checkbox").click(function(){ | |
if($("#checkbox").is(':checked') ){ | |
$("#e1 > option").prop("selected","selected"); | |
$("#e1").trigger("change"); | |
}else{ | |
$("#e1 > option").removeAttr("selected"); | |
$("#e1").trigger("change"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment