您好,我的 js 代码有问题。我收到错误 Uncaught SyntaxError: Unexpected token 'delete'。我只是不明白我在创建一个函数时会做错什么。
<script type="text/javascript">
window.onload = function()
{
var id_count = 1;
var btn = document.getElementById("add_product");
btn.addEventListener("click", function()
{
id_count += 1;
document.getElementById("products_table").innerHTML +=
"<tr id='" + id_count +"'>\
<td>" + id_count +"</td>\
<td><input type='text' class='form-control' name='name' id='name" + id_count +"' placeholder='Jane Doe'></td>\
<td><input type='number' class='form-control' name='count' id='count" + id_count +"' placeholder='jane.doe@example.com'></td>\
<td><input type='text' class='form-control' name='price_netto' id='price_netto" + id_count +"' placeholder='jane.doe@example.com'></td>\
<td class='input-group'><input type='text' class='form-control' name='vat_rate' id='vat_rate" + id_count +"' placeholder='jane.doe@example.com'>\
<span class='input-group-addon'>%</span>\
</td>\
<td><input type='text' class='form-control' name='price_brutto' id='price_brutto" + id_count +"' placeholder='jane.doe@example.com'></td>\
<td><button type='button' onclick='document.getElementById(" + id_count +").remove();' class='btn btn-alert'>Usuń</button></td>\
</tr>";
}, false);
function delete()
{
}
}
</script>