How can I add onclick event to a table column?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to add an onclick event to a table column using JavaScript. For example, an onclick event enabled on the first or second column! The following function is for rows, but I need to edit this function for specific columns. function addRowHandlers() { var table = document.getElementById("tableId"); var rows = table.getElementsByTagName("tr"); for(i = 0; i < rows.length; i++) { var currentRow = table.rows[i]; var createClickHandler = function (row) { return function () { var cell = row.getElementsByTagName("td")[0]; var id = cell