change() for appended select doesn't work

前端 未结 4 895
太阳男子
太阳男子 2021-01-03 11:52

I\'ve jQuery function on change for a select element:

$(\"#category\").change(function(){
    $(\"table[id=advance_search]\").append(\"

        
4条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-03 11:57

    You need to subscribe with on() function, because when you subscribong with change element doesn't exists in DOM and jQuery can't find it.

    $("select[id=type]").on('change', function(){
         console.log("change");
    });
    

提交回复
热议问题