<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<button id="btn" style="margin-bottom: 20px">remover</button>
<table id="t">
<tbody>
<tr>
<td>lorem1</td>
<td>lorem2</td>
<td>lorem3</td>
<td>lorem4</td>
</tr>
</tbody>
</table>
<div id="result"></div>
<script>
var copyToResult = function(){result.innerHTML = "<pre>" + t.innerHTML.replace(/</g, "<").replace(/>/g, ">") + "</pre>"}
var re = /(\r\n\s*\r\n)+|(\n\s*\n)+/g
var removeEmptyLines = function(){
result.innerHTML = result.innerHTML.replace(re, function(s){if(/\r/.test(s)) return "\r\n"; return "\n"})
}
copyToResult()
btn.onclick = function(){
var cols = t.querySelectorAll("td")
if (!cols.length) return
cols[cols.length - 1].remove()
copyToResult()
removeEmptyLines()
}
</script>
</body>
</html>