jQuery - cannot bind events to dynamic elements?

后端 未结 6 572
借酒劲吻你
借酒劲吻你 2021-01-13 07:58

I\'ve come to maintain a piece of javascript that downloads some JSON data from the server, builds a new table row (like $(\') and inserts i

6条回答
  •  情话喂你
    2021-01-13 08:17

    Try binding the function within the scope of the function where you dynamically create the element.

    $('a.foo').on('click',function(event){
     //your code goes here
    });
    

提交回复
热议问题