jQuery动态增加节点和删除节点

预览效果
html




    
    
    
    Document


    
    

js

$(function () {
    // 模板字符串 
    let box = `
`; // 增加节点 $('#add').click(() => { $('.container').append(box); }); // 删除对应节点 $(document).on('click', '.del', function () { $(this).parent().remove(); }); })

你可能感兴趣的:(jQuery动态增加节点和删除节点)