Showing posts with label Select2. Show all posts
Showing posts with label Select2. Show all posts

Tuesday, 22 July 2014

Select2 get value and label of selected option

Que: How to get the value and label of option from select2 using jQuery?

Ans:

var theID = jQuery("#tags").select2('data').id;
var theSelection = jQuery("#tags").select2('data').text;

Here #tags is the id of your select2 field in html code.