Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Chosen - get (multiple) selected labels (not the value)

How to get the selected option's text from the Chosen select? So not just the .val() but the option label/text

like image 657
COBIZ webdevelopment Avatar asked Oct 19 '13 12:10

COBIZ webdevelopment


5 Answers

The only way that work for me, was doing something like this:

var options = $("#ddl option:selected");

var values = $.map(options, function (option) {
    return option.text;
});

Where values is an array.

Hope that it helps...

like image 54
Daniel Avatar answered Nov 08 '22 15:11

Daniel


//Below code return name of the drop downn

$('#availableRevisionBatch option:selected').text() 

//Below code return value of the drop downn

$('#availableRevisionBatch option:selected').val() 
like image 22
Mohamed Sabirulla Avatar answered Nov 08 '22 15:11

Mohamed Sabirulla


You can simply use this to get the label.

$('.result-selected').html() 

or

$('.options option:selected').html() 
like image 42
123 Avatar answered Nov 08 '22 16:11

123


Used: $("#list option[value='"+id+"']").text(); To retrieve the label of the selected value

like image 45
COBIZ webdevelopment Avatar answered Nov 08 '22 16:11

COBIZ webdevelopment


$("#objId option :selected").text();

Above jQuery statement should do it for.

like image 30
Adesh M Avatar answered Nov 08 '22 14:11

Adesh M