inser a row
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>Insert row in a table - w3resource</title>
</head>
<body>
<table id="sampleTable" border="1">
<tr>
<td>Row1 cell1</td>
<td>Row1 cell2</td>
</tr>
<tr>
<td>Row2 cell1</td>
<td>Row2 cell2</td>
</tr>
</table><br>
<input type="button" onclick="insert_Row()" value="Insert row">
<script>
function insert_Row(){
let table = document.getElementById('sampleTable');
table.insertAdjacentHTML('beforeEnd', `<tr><td>Row3 Cell1</td><td>Row cell2</td></tr>`)
}
</script>
</body>
</html>
Comments
Post a Comment