Topic: How to dynamically add or remove chips ?
Here I am going to explain how to add chips dynamically.
Add the below line in your html.
<div class="chips chips-initial"></div>
Add below code into JS function.
var s = "your_input"; var e = jQuery.Event("keydown"); e.which = 13; // # Some key code value $(".chips-initial input").val(s); $(".chips-initial input").trigger(e); $('.chips').material_chip();
Note:Pass Your input into variable s;
That's working. But how to prevent XSS as tag input e.g.: alert('Hi');
You don't have to be worried about XSS becouse
val() doesn't couse XSS