jQuery: How to add event handler to dynamically added HTML elements?

前端 未结 4 964
心在旅途
心在旅途 2020-12-03 12:36

I have the following code:

$(document).ready(function({
    $(\".click\").click(function(){
        alert(\' The Button Was Clicked !\');
    });
}));

4条回答
  •  一向
    一向 (楼主)
    2020-12-03 13:22

    for all the elements added dynamically to DOM at run time , please use live

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

提交回复
热议问题