📌  相关文章
📜  向尚不存在的元素添加事件侦听器 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:05.959000             🧑  作者: Mango

代码示例1
// You need to add the event listener when the element is created.
function createEventListener() {
      var node = document.createElement('div');
    if (node) {
        node.addEventListener('click', function() {
            console.log('Clicked Node');
        });
    } else {
            console.error('No node');
    }
}