Reputation: 5546
<select id="showOption">
<option id="1">All Friends</option>
<option id="2">Friends who run</option>
<option id="3">Friends who don't run</option>
</select>
How can I respond to a user selecting one option or another using jQuery? What is the event, and how does the source look like?
For ex for a button I use (#myButton).click( func()...
Upvotes: 2
Views: 812
Reputation: 175038
The event is called change()
. Manual entry.
$('#showOption').change(function() {
//$(this).val() = The value of the select.
});
Upvotes: 3
Reputation: 41256
You would do something like this:
$('#showOption').change(function()
{
var value = this.id;
// Do Stuff
});
Of course, your HTML isnt entirely great here; you should be relating data on the 'value' attribute, not Id.
Upvotes: 3