Skip to content Skip to sidebar Skip to footer

Jquery Click Event Not Working On Option Element

Why doesn't the following code work? $('select option').live('click', function(){ alert('hello') }) html:

Solution 1:

Do this instead:

$('select').change(function(){
    alert('hello');
});

If you need to know the selected value inside the event handler, then you can do this:

$('select').change(function() {
    var selectedOption = $(this).val();
});

http://jsfiddle.net/FishBasketGordo/2ABAh/

Post a Comment for "Jquery Click Event Not Working On Option Element"