Get the selected option id with jQuery
Posted
by Itamar Bar-Lev
on Stack Overflow
See other posts from Stack Overflow
or by Itamar Bar-Lev
Published on 2010-05-22T14:29:11Z
Indexed on
2010/05/22
14:30 UTC
Read the original article
Hit count: 330
Hi, I'm trying to use jQuery to make an ajax request based on a selected option.
Is there a simple way to retrieve the selected option id (e.g. "id2") using jQuery?
<select id="my_select">
<option value="o1" id="id1">Option1</option>
<option value="o2" id="id2">Option2</option>
</select>
$("#my_select").change(function() {
//do something with the id of the selected option
});
© Stack Overflow or respective owner