Bootstrap tagsinput maxTag not working inside a function

163 Views Asked by At

I have a code when the select input is changed the maxTag of tagsinput must be set to 1 but is not working. here's my code:

Html:

<select class="selection-2" id="sections" name="sections">
        <option value="1">solo</option> 
  </select>
<input data-role="tagsinput" type="text" class="form-control" id="mytags" name="mytags"> 

Javascript:

$("select[name=sections]").change(function() {
        var sections= $(this).val();
        switch (sections) {
            case '1':
                solo();
                break; 
        }
    });

    function solo() { 
        $("#mytags").tagsinput({
            maxTags: 1
        });  
   }
0

There are 0 best solutions below