Solved

select text of menu

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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)

758 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

27 Experts available now in Live!

Get 1:1 Help Now