jQuery event when select option

后端 未结 3 972
[愿得一人]
[愿得一人] 2020-12-14 00:01

What\'s the event to bind for when a select form is selected?

I have something like this:


                        
    
提交评论

  • 2020-12-14 00:52

    This jQuery snippet will get you started:

    $('#list').change(function() {
        if ($(this).val() === '2') {
            // Do something for option "b"
        }
    });
    
    0 讨论(0)
  • 2020-12-14 00:55

    the event you are looking for is change. more info about that event is available in the jquery docs here: http://docs.jquery.com/Events/change#fn

    0 讨论(0)
  • 提交回复
    热议问题