0

I have a field called City that is a drop down. It has a key value pair.

To get the value, I can simply do the following in Jquery:

    var city = $("#city").val();

How do I get the key value though?

2
  • 1
    what would be the key in your example? Commented Apr 24, 2012 at 14:59
  • 1
    Does this mean the option elements have a value and non-standard key attribute? Your question does not contain sufficient information to be answered. Commented Apr 24, 2012 at 15:02

2 Answers 2

1

so you want the text of the selected option:

$('#city').find('option:selected').text();
Sign up to request clarification or add additional context in comments.

Comments

0

if it's a option within a select, try .text().

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.