Last active
March 15, 2017 15:09
-
-
Save tranquangchau/7a35b32717109e20f19072abff9b79cb to your computer and use it in GitHub Desktop.
http://jsfiddle.net/jEADR/62/ select2 demo
This file contains 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
<!--<script type="text/javascript" src="https://select2.github.io/vendor/js/jquery.min.js"></script>--> | |
<script type="text/javascript" src="https://select2.github.io/dist/js/select2.full.js"></script> | |
<!--<link href="https://select2.github.io/css/bootstrap.css" type="text/css" rel="stylesheet" />--> | |
<link href="https://select2.github.io/dist/css/select2.min.css" type="text/css" rel="stylesheet" /> | |
<select multiple id="e1" style="width:300px"> | |
<option value="AL">Alabama</option> | |
<option value="Am">Amalapuram</option> | |
<option value="An">Anakapalli</option> | |
<option value="Ak">Akkayapalem</option> | |
<option value="WY">Wyoming</option> | |
</select> | |
<input type="checkbox" id="checkbox" >Select All | |
<input type="button" id="button" value="check Selected"> |
This file contains 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
$("#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"); | |
} | |
}); | |
$("#button").click(function(){ | |
alert($("#e1").val()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment