简体   繁体   中英

why don't work checkbox's onclick using ajax?

I am currently creating tables and checkboxes using ajax communication.

After it was created, it was confirmed that the checkbox function was working normally, Even if I include checked while creating it, the Onclick function doesn't fire.

success:function(data){
    for (var key in data) {
        feature = data[key]
        head = feature[0].split(" ")
        tail = feature[1].split(" ")
        type = feature[2]
        name = feature[3]
        $('#pharmacophore_table').append("<tr>" + 
            "<td>" + name + "</td>" +
            "<td> <label><input type='checkbox' name='ligand_feature' onclick='show_ligand_feature(this, " + '"' + feature + '"' + ");' ></label>" + 
            "</tr>");

        $("input[name='ligand_feature']").attr( "checked", true);
    }      
},
error:function(data){
    alert(data.status)
}

How can I solve this?

I solved it.

Just add click event

complete: function(){
    var chck = document.getElementsByName('ligand_feature')
    for (var l=0; l<chck.length; l++){
        chck[l].click();
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM