Topic: How to dynamically add or remove chips ? pro asked 5 years ago

I want to modify chips in an input using javascript. Can anyone help me with this requirement ?

Tomek Makowski staff answered 3 years ago

You don't have to be worried about XSS becouse val() doesn't couse XSS


terbach free answered 3 years ago

That's working. But how to prevent XSS as tag input e.g.: alert('Hi');

vasanth G free answered 4 years ago

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);

Note:Pass Your input into variable s;

Please insert min. 20 characters.


Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.



Specification of the issue

  • User: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No