wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes JQuery: Getting Select Options Label Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JQuery: Getting Select Options Label" Watch "JQuery: Getting Select Options Label" New topic
Author

JQuery: Getting Select Options Label

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

So I know the cool old fasioned way of getting to a select element options label:

document.getElementById('modelId').options[document.getElementById('modelId').options.selectedIndex].text

My first question is does JQuery have a built in util function to do this?
My second question is, if not, I've started my own but I can't seem to figure out how to return the value from the custom function:



And then doing something like:

jQuery('#someSelectElement').getSelectedLabel()

is returning 'undefined'.

Thanks for any help.


GenRocket - Experts at Building Test Data
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Figured it out:

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JQuery: Getting Select Options Label
 
Similar Threads
need help in jquery
Sorting array in bind("change", function()
JSON+Jquery
Trying to use tagify plug-in to populate text field with dynamic labels
Ajax code getting null value