how to trigger click event on dynamically created element in jquery

后端 未结 4 898
清酒与你
清酒与你 2021-01-12 02:18
if($(\'#term\').children().length == 0){
        $(\"#term\").append(\"
    \"); var i; for(i=1;
    4条回答
    •  孤街浪徒
      2021-01-12 02:53

      I have seen your ID is starting with Term so you can use .on() to add click event on DOM that are added later.

      Exapmple

      $(document).on('click','[id^="Term"]',function(){
        //code here
      });
      

    提交回复
    热议问题