Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!