Skip to content

Instantly share code, notes, and snippets.

@Faizanq
Created October 18, 2018 06:29
Show Gist options
  • Save Faizanq/f9647cba5f210df2cfb374649e03c8ca to your computer and use it in GitHub Desktop.
Save Faizanq/f9647cba5f210df2cfb374649e03c8ca to your computer and use it in GitHub Desktop.
$('#mySelect2')
.empty() //empty select
.append($("<option/>") //add option tag in select
.val("20") //set value for option to post it
.text("nabi")) //set a text for show in select
.val("20") //select option of select2
.trigger("change"); //apply to select2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment