Communities for your favorite technologies. Explore all Collectives
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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?
option
value
key
so you want the text of the selected option:
$('#city').find('option:selected').text();
Add a comment
if it's a option within a select, try .text().
.text()
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
optionelements have avalueand non-standardkeyattribute? Your question does not contain sufficient information to be answered.