HTML multiple tag selection input.
- Copy and paste the following css link and js script to your html file.
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/habibmhamadi/multi-select-tag@3.1.0/dist/css/multi-select-tag.css">
<script src="https://cdn.jsdelivr.net/gh/habibmhamadi/multi-select-tag@3.1.0/dist/js/multi-select-tag.js"></script>
- Give an id and
multiple
attribute to your select element.
<select name="countries" id="countries" multiple>
<option value="1">Afghanistan</option>
<option value="2">Australia</option>
<option value="3">Germany</option>
<option value="4">Canada</option>
<option value="5">Russia</option>
</select>
- Call the function and pass the id.
<script>
new MultiSelectTag('countries') // id
</script>
- You can pass a second optional paramater for border-radius, shadow, placeholder, tag color and listening to
onchange
event.
new MultiSelectTag('countries', {
rounded: true, // default true
shadow: true, // default false
placeholder: 'Search', // default Search...
tagColor: {
textColor: '#327b2c',
borderColor: '#92e681',
bgColor: '#eaffe6',
},
onChange: function(values) {
console.log(values)
}
})
Report bugs and suggest feature in issue tracker. Feel free to Fork
and send Pull Requests
.