Reputation: 15384
I was wondering if the following is possible. I would like to fire different events depending upon which option is selected in a dropdown. So far I thought of this but nothing is happening when I select the option
$('#strand_id option[value="5"]:selected').on('click', function(){
console.log('something just happened!!!')
});
I don’t think I can use the change method as this will apply the same event no matter what option is selected (unless there is a way?).
Upvotes: 0
Views: 33
Reputation: 207953
Try this:
$('#strand_id').on('click ', function () {
if (this.value == 5) console.log('something just happened !! !')
});
Upvotes: 1