How to add a new options to JQuery Chosen Plugin Dynamically

1 Comment

If users is the id of the select Chosen dropdown box, then use JQuery to append new options dynamically as in the example below

$("#users").append('<option value="1">User</option>').trigger("chosen:updated");

.trigger(“chosen:updated”);  refreshes the Chosen dropdown box with the new option.

Image Credits: Photo by Isis França on Unsplash.

Related Articles

No results found

1
Leave a Reply

avatar
1 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
1 Comment authors
vinayak kadam Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
vinayak kadam
Guest
vinayak kadam

Thanks for this, very helpful…

Menu
Copy link