Bind click event on select option

前端 未结 7 1349
长情又很酷
长情又很酷 2021-01-17 21:54

I\'ve got a problem making a click event on an HTML option element work.

Even a simple console.log(\'hello!\'); won\'t work.

7条回答
  •  深忆病人
    2021-01-17 22:18

    You can bind using .on() by giving .

    So, there is no need to mention option while binding event.

    $(document).on('change','#mySelect', function(){
    console.log('hi!'); });

    OR

    $('#mySelect').bind('change',function(){
    console.log('hi!'); });

提交回复
热议问题