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

138
Vistas
How to detect if an element is a form element

In my code, I am trying to detected if the last clicked on element is a form element where setting its name attribute would be appropriate.

What I've written works:

    const tag = lastElement.tagName;
    if (tag === "INPUT" || tag === "TEXTAREA" || tag === "SELECT") {
      ...
    }

But I am wondering if there is a more robust/elegant way to do this, like

    if (lastElement instanceof FormFieldElement) {
      ...
    }

Is there such a common class?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I went and researched this myself. According to Mozilla MDN, there's no common element after HTMLElement

https://developer.mozilla.org/en-US/docs/Web/API/HTMLTextAreaElement https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement

(Select also doesn't share class hierarchy)

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