我想为每一行添加复选框,但是当我尝试运行代码时,这样的内容显示“[object HTMLInputElement]”而不是复选框
function BSIT(){
$("#stdlist").empty();
var chyear = $('#chyear').val();
$("#showtxt").html(chyear);
var checkbox = document.createElement("INPUT");
checkbox.type = "checkbox";
var ref = firebase.database().ref().child("course/BSIT");
ref.orderByChild("Year").equalTo(chyear).on("child_added", function(snapshot) {
var childData = snapshot.val();
$("#stdlist").append("<tr> <td>" + checkbox + "</td><td>" + childData.StudentId +
"</td><td>" + childData.FirstName +" "+ childData.Lastname +
"</td><td>" + childData.Address +
"</td><td>" + childData.Gender +
"</td><td>" + childData.Age +
"</td><td>" + childData.Phone +
"</td><td>" + childData.Year +
"</td></tr>"
);
});
答案 0 :(得分:0)
试试这个:
function BSIT(){
$("#stdlist").empty();
var chyear = $('#chyear').val();
$("#showtxt").html(chyear);
var ref = firebase.database().ref().child("course/BSIT");
ref.orderByChild("Year").equalTo(chyear).on("child_added", function(snapshot) {
var childData = snapshot.val();
$("#stdlist").append("<tr> <td>" + '<input type="checkbox">'+ "</td><td>" + childData.StudentId +
"</td><td>" + childData.FirstName +" "+ childData.Lastname +
"</td><td>" + childData.Address +
"</td><td>" + childData.Gender +
"</td><td>" + childData.Age +
"</td><td>" + childData.Phone +
"</td><td>" + childData.Year +
"</td></tr>"
);
});
我希望它会对你有所帮助:)。