Hello I've tried several things to give my submit button the onsubmit attribute. But I can't figure out, how to set onsubmit. Maybe you have an idea.
let btn = document.createElement('input');
btn.value = "Delete";
btn.name = "deleteButton";
btn.type = "submit";
btn.onsubmit="deleteCell();
let btn = document.createElement('input');
btn.value = "Delete";
btn.name = "deleteButton";
btn.type = "button";
btn.addEventListener('submit', deleteCell())
The "submit" event is for a form, not an input. You can use the "click" event on the input through:
const deleteCell = () => {
console.log("hello World!")
};
let btn = document.createElement('input');
btn.value = "Delete";
btn.name = "deleteButton";
btn.type = "button";
btn.addEventListener('click', deleteCell);