There is a table, when you click on any first cell, the initExpandableTableRows() method is initExpandableTableRows() , and if you click on any other cell, the initTableRows() method is initTableRows() . The code is incorrect. I'm a newbie
function addOnclickToDatatableRows() { var tds = $('[id*=dataTable] tr td:first-child').get(); var trs = $('[id*=dataTable] tbody:first tr').get(); for (var i = 0; i < tds.length; i++) { tds[i].onclick = new Function("selectFirstCell()"); trs[i].onclick = new Function("selectRow()"); } } function selectFirstCell() { initExpandableTableRows(); } function selectRow(){ initTableRows(); }