Getting selected text of a select listbox using JQuery when I already have the select object in hand -


Here's an easy newbie question:

I know that it is possible to get it This way the text of the selection option

  $ ('# selectBoxId option: selected'). Val ();   

But if I already have a selection object in my hand?

For example, select

  var = $ ('# selectBoxId');   

What comes next? Is this the right way?

  select.find ('option: selected'). Val ();    

simply select.val (); is enough it will give you the selected value .

The task

If you want the text to choose the desired option

  select.find ('option: selected'). Text ();   

or

  select.find ('Options: Selected'). Html ();    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -