File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JQuery: Getting Select Options Label