Created
October 15, 2012 18:51
-
-
Save okwme/3894341 to your computer and use it in GitHub Desktop.
multiple select without need for command key
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
var selected = []; | |
$(document).ready(function(){ | |
$("#selected option:selected").each(function(i){ | |
selected.push($(this).val()); | |
}); | |
$("#selected").click(function(e){ | |
if($.inArray(e.target.value, selected) > -1){ | |
selected.splice($.inArray(e.target.value, selected),1); | |
}else{ | |
selected.push(e.target.value); | |
} | |
$(this).val(selected); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment