The question itself was asked many times but I couldn´t find a similar example like I wrote. My request is simple, I want to add rows which are editable. To do so I created a plus button which adds a row. Unfortunately this row´s aren´t editable, even if the innerHTML is set to be able to.
Any idea without jquery?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<style>
table, th, td {
border: 1px solid black;
}
</style>
<body>
<div id="wrapper">
<button id="addRow">+</button>
<button id="deleteRow">-</button>
<table id="table">
<tbody>
<!-- filled by script -->
</tbody>
</table>
</div>
<script>
// add row
document.getElementById("addRow").addEventListener("mouseup", function() {
var table = document.getElementById("table")
var row = table.insertRow(0);
var cell0 = row.insertCell(0);
var cell1 = row.insertCell(1);
cell0.innerHTML = '<td contenteditable="true">Property</td>';
cell1.innerHTML = '<td contenteditable="true">Value</td>'
})
</script>
</body>
</html>