select text of menu

Posted on 2013-12-01
Last Modified: 2013-12-01
Instead of selecting the value of an option, I need to select the text between the option tags

for example in a menu like this

<select id="testmenu">
    <option value=1>First label</option>
    <option value=2>Second label</option>

For example on select the second option, I  want to get     Second label.
Question by:debbieau1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 44

Accepted Solution

Rainer Jeschor earned 500 total points
ID: 39689203
you simply have to get the option element in jQuery and then use the text() function:
$("#testmenu option:selected").text();

Open in new window

will display the selected option.



Author Closing Comment

ID: 39689210
Thanks I tried .text()  but had mistyped.  Thanks again.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP: Filling Out/Creating a PDF 29 113
Worldmap 1 28
Table header must be on top 2 31
Post from Jquery mobile form goes wrong in classic asp action page 2 9
Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question