aspose 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


Win a copy of Java 8 in Action this week in the Java 8 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: 15290
    
    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: 15290
    
    6

Figured it out:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JQuery: Getting Select Options Label
 
Similar Threads
need help in jquery
Sorting array in bind("change", function()
JSON+Jquery
Ajax code getting null value
Trying to use tagify plug-in to populate text field with dynamic labels