Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tagging doesn't work in select2

ok, I have this simple select2 which needs tagging support. My code :-

<select name="x1" id="x1" style="width: 20%">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
</select>

JS :-

$(document).ready(function(){
    $("#x1").select2({
        tags: true
    });
});

My select2 should have tagging support, but it doesn't happen with my code. What wrong am I doing? Jsfiddle :- https://jsfiddle.net/u4euvsw0/


1 Answers

You have to add "multiple" attribute to make it works

<select name="x1" id="x1" style="width: 20%" multiple="multiple">
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
</select>
like image 119
byakugie Avatar answered Oct 29 '25 22:10

byakugie