change() for appended select doesn't work

前端 未结 4 927
太阳男子
太阳男子 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 12:15

    try this:

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

    As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().

    source:http://api.jquery.com/live/

提交回复
热议问题