Why is my jquery .on('change') not working for dynamically added selects

前端 未结 10 560
既然无缘
既然无缘 2020-12-31 01:12

I\'m adding select elements dynamically, like in the below HTML. I\'m not sure why the .on(\'change\' ...) is not working for the dynamic select. What am I missing?

<
10条回答
  •  南笙
    南笙 (楼主)
    2020-12-31 01:44

    Don't use .live()/.bind()/.delegate(), though. You should use .on().

    for both static and dynamic select changes

    $(document).on('change', 'select', function (e) {
        // do something 
    });
    

提交回复
热议问题