javascript - How can we add the static label for select2 -
in application using select2 plugin drop-down multiple select values. , want add static option select2 drop-down.
<select multiple="" class="test"> <option value="a">illustrations</option> <option value="b">maps</option> <option value="add">add status</option> </select>
and applying multi select, when click on add status option want functionality , option not selected option.
and js code :
$('.test').select2(); $('.test').on("select2-selecting", function(e) { alert($(".test").val()); });
but alert
giving selected values a,b,add
. want 'add'
option only.
please suggest me how can this.
thanks in advance.
try this:
alert($(".test option:selected").val());
Comments
Post a Comment