The correct way to get the selected option in jquery from an object

I saw in StackOverflow and googling that the most used way to get selected text from a <SELECT> element with jquery is like this

 $("#cboId :selected").text() 

I have not an id, but an object. I have an object, let's say

 var myCombo= $("#cboId"); 

based on the earlier part of the code.

I did it to get the selected text, but ugly:

  $("#" + myCombo.attr('id') + " :selected").text() ; 

is there a cleaner way to do this?

thanks.

+6
javascript jquery select option
source share
1 answer
 var selectedText = $(":selected",myCombo).text(); 
+18
source share

All Articles