在加载页面后生成按钮时单击按钮上的事件

时间:2016-05-04 09:29:25

标签: javascript jquery html

在我的代码中,我出于某些原因用jquery复制了一段html代码。在这段代码中,我有一个按钮。单击初始按钮时,页面中会显示一些内容。但问题是我在jquery中生成的新按钮不会运行该事件。它什么都不做。

我的按钮(在表格中):

<button><span class="glyphicon glyphicon-zoom-in afficher_itk" aria-hidden="true"></span></button>

重复的方式:

    var table = document.getElementById("table_cultures");

    var row = document.getElementById('clonedRow');
    var clone = row.cloneNode(true);

    table.appendChild(clone);

“onclick”功能:

$(".afficher_itk").click(function(){
    //do something
});

0 个答案:

没有答案