Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

204
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda