views:

148

answers:

1

hi. I've seen on StackOverflow and googling around that the most used way to get the selected text from a <SELECT> element with jquery is like this

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

what I have is not the id, but an object. I have an object, say

var myCombo= $("#cboId");

coming from an earlier piece of code.

I've done like this to get the selected text, but is ugly:

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

is there any cleaner way to do it?

thanks.

+2  A: 
var selectedText = $(":selected",myCombo).text();
Philippe Leybaert
this looks nice! thanks
pomarc