Solved

select text of menu

Posted on 2013-12-01
2
327 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jQuery Syntax 2 47
Loop and hide/show dropdown option with jQuery 4 22
two layers of simple javascript validation 2 28
CONVERT JAVASCRIPT BUTTON TO HYPERLINK TEXT 6 20
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
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)
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…

867 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now