Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: How to dynamically add or remove chips ?

Accident.com pro asked 6 years ago


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

Tomek Makowski staff answered 5 years ago


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

Best


terbach priority answered 5 years ago


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


vasanth G free answered 5 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);
$('.chips').material_chip();

Note:Pass Your input into variable s;



Please insert min. 20 characters.

FREE CONSULTATION

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

Status

Answered

Specification of the issue

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