Skip to content

Instantly share code, notes, and snippets.

@juanhuttemann
Created October 14, 2019 16:29
Show Gist options
  • Save juanhuttemann/873d27e13cc8cb47c2f183f273f3ae76 to your computer and use it in GitHub Desktop.
Save juanhuttemann/873d27e13cc8cb47c2f183f273f3ae76 to your computer and use it in GitHub Desktop.
set to selected option with Select2
var option = new Option("text", "1");
option.selected = true;
$(".select2").append(option);
$(".select2").trigger("change");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment