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

168
Vistas
Java script 'document on change select function' and 'document ready function - select change function'

We are reviewing our project and trying to make it as standard as possible along all pages. We came across some possible approaches, below described, which seems to work the same (our software is restricted to Chrome).

Are there any differences we may have not noticed?

Option A:

$(document).on('change', "#selectAAA", function () { ... }
$(document).on('change', "#selectBBB", function () { ... }

or

Option B:

$(document).ready(function () {
   $("#selectAAA").change(function () { ... }
   $("#selectBBB").change(function () { ... }
   }
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Option A is for delegation from document. It is quite heavy if many elements

$(document).on('change', "#selectAAA", function () { ... }
$(document).on('change', "#selectBBB", function () { ... }

I prefer Option C for static elements

$(function () {
  $("#selectAAA").on("change", function () { ... });
  $("#selectBBB").on("change", function () { ... });
})

Or you can delegate any select - this is similar to option A

Option D

$(function () {
  $(document).on('change', "select", function () {
    if ($(this).is("#selectAAA")) {
    }
    else if ($(this).is("#selectBBB")) {
    }
  })
})
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