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

203
Vistas
gettng the element and selected value outside the calling function in jquery

I want to get the element and the passing value outside the calling function for dropdown change event .methodB need to be called inside methodA. But element and selected value related to methodB can't get inside methodeA unless related change event has been called inside methodA.when I do that to execute the code getting too slow.

(function(document, $) {
    var $doc = $(document);
    $doc.on('foundation-contentloaded', function(e)) {
      var selectedValueA;
      var selectedValueB;
      $('.class_x').each(function(i, element)) {
        $(this).on(“change”, function(event)) {
          selectedValueA = event.target.value;
          methodA($(this), selectedValueA);
        }
        selectedValueA = $(this).val();
        methodA($(this), selectedValueA);
      });

    $('.class_y').each(function(i, element)) {
      $(this).on(“change”, function(event)) {
        selectedValueB = event.target.value;
        methodB($(this), selectedValueB);
      }
      selectedValueB = $(this).val();
      methodB($(this), selectedValueB);
    });

});

function methodA(element, isSelected) {
  if (isSelected == 'a') {
    //problem is how to call methodB inside methodA cas element and isSelected related methdB is not inside methodA.
    //I can’t call each function related to methodB here as it is taking too much time to execute  the code 
  }

  function methodB(element, isSelected) {}
})(document, Granite.$)
about 4 years ago · Juan Pablo Isaza
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