在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML5/ angular2 用的jq寫的,append 的div里面要加入click事件,

angular2 用的jq寫的,append 的div里面要加入click事件,可是動(dòng)態(tài)添加的div綁定不了事件,怎么解決?

$("#sel").blur(function () {

        $("#items").css({
            "display": "none"
        })

        $('input[type="checkbox"]:checked').each(function (elementId) {
            
            a.push((<HTMLInputElement>this).value); //push 進(jìn)數(shù)組
            b.push((<HTMLInputElement>this).value); //push 進(jìn)數(shù)組
            for (const key in a) {
                if (a.hasOwnProperty(key)) {
                    $("#wal2").append("<lable class='gongan'>" + a[key] + "<span class ='span' style='display: inline;' onclick='cli1(this)'>" + "X" + "</span></lable>")
                    //                            console.log($("#wal2"));
                }
            }
            a = [];
        });

        //                console.log(b);
        obj.gongan = b.join(",");
        console.log(obj);
    })
回答
編輯回答
笨尐豬
$("#sel").on('blur', function() {
    xxxxx
})

jq用on進(jìn)行事件委托,動(dòng)態(tài)生成的div才有觸發(fā)事件

2018年5月15日 22:02