Onclick event does not work. Is it possible that element "td" can't have listener?
for (element in arr_big) {
var cellOne = document.createElement("td");
cellOne.innerHTML = '"<img src = "' + arr_big[element].src + '"/>"';
cellOne.onclick = function showImage(cellOne) {
console.log(cellOne.innerHTML);
};
row.appendChild(cellTwo);
list_table_one.appendChild(row);
}
Thanks for any help.
No, it can have a listener, but it has to be attached to the dom first
document.appendChild( cellOne );
before binding the event
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.