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

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -