Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

118
Vistas
Is it possible to give a submit input button the onsubmit attribute with javascript?

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())
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

The "submit" event is for a form, not an input. You can use the "click" event on the input though:

const deleteCell = () => {
    console.log("hello World!")
};
let btn = document.createElement('input');
btn.value = "Delete";
btn.name = "deleteButton";
btn.type = "button";
btn.addEventListener('click', deleteCell);
about 4 years ago · Juan Pablo Isaza Denunciar

0

A button does not have a onSubmit or submit event.

onSubmit is a property of a <form> element.

With button, you should use btn.onClick = deleteCell or addEventListener('click',deleteCell)

Have a look here for more details on a similar question.

onSubmit event on a button element will it work?

about 4 years ago · Juan Pablo Isaza Denunciar

0

What exactly are you trying to achieve? Usually a submit button is wrapped inside a <form> tag. The form might have a onSubmit attribute or an action and a method. A button can have the onClick attribute to run a specific function.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda