Table add row
by Fernando De Leon
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<div class="container">
<table id="myTable" class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Surname</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input type="text" >
</td>
<td><input type="text"></td>
<td><button id="btn">Add</button></td>
</tr>
</tbody>
</table>
</div>
JavaScript
$("#btn").on("click",function() {
console.log("have click");
var epoch = new Date().getTime();
$("#myTable").
append("<tr><td class='a'>sssomething "+epoch+"</td><td class='b'>Other</td><td><button class='edit'>Edit me</button></td></tr>");
console.log($("button.edit").text());
$(document).trigger("editButtonDone");
});
function clickEdit(val) {
console.log("the click is done for edit:"+val);
}
$(document).on("editButtonDone",function() {
$("button.edit").on("click",function() {
console.log("herer")
var thisTd = $(this).parent().parent();
var trHtml = thisTd.html();
var value = $(trHtml).find("td.a");
console.log(value);
// console.log(thisTd.html());
});
});