Solved

select text of menu

Posted on 2013-12-01
2
341 Views
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>
</select>

For example on select the second option, I  want to get     Second label.
0
Comment
Question by:debbieau1
2 Comments
 
LVL 44

Accepted Solution

by:
Rainer Jeschor earned 500 total points
ID: 39689203
Hi,
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.

Sample:
http://jsfiddle.net/EE_RainerJ/uuRUK/

HTH
Rainer
0
 
LVL 1

Author Closing Comment

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create an automated page index 9 47
IFrame in MVC 2 23
Html input text color the frame line 2 19
JQuery Search Filter 2 27
In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

790 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