I have a given row object $row
and there are already columns in it, I would like to insert a new column with html text at first position.
like
var cell = $row.insertCell(0);
cell.innerHTML = "<input type='button' value='Add'/>";
I have a given row object $row
and there are already columns in it, I would like to insert a new column with html text at first position.
like
var cell = $row.insertCell(0);
cell.innerHTML = "<input type='button' value='Add'/>";
You can try this script to solve your issue.
<!DOCTYPE html>
<html>
<head>
<title>Try jQuery Online</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
var row = $("#tbl1-tr0");
var cell = document.createElement("td");
row.find('td').eq(0).before(cell);
cell.innerHTML = "<input type='button' value='Add'/>";
});
</script>
</head>
<body>
<table id="tbl1">
<tr id="tbl1-tr0">
<td>Name</td>
<td>Age</td>
</tr>
</table>
</body>
</html>