How to clear Tokenize2 input fieds?

635 views Asked by At

Are there anyway to clear the select option in Tokenize2 by using javascript or jquery?

And this is my code.

<select class="select-continent" multiple>
    <option value="Africa">Africa</option>
    <option value="Americas">Americas</option>
    <option value="Asia">Asia</option>
    <option value="Europe">Europe</option>
    <option value="Oceania">Oceania</option>
</select>

$('.select-continent').tokenize2({
    dataSource: 'select'
});

After i select some option as the result. How can i clear all select option in the input field?

enter image description here

1

There are 1 answers

1
mahi-man On BEST ANSWER

Check out the events documentation: https://dragonofmercy.github.io/Tokenize2/events.html

You can clear by triggering the clear event:

$('.select-continent').tokenize2().trigger('tokenize:clear')