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

143
Views
Can not modify variable and get new value outside a function (in a class) Javascipt

I want to modify a variable which is inside a function in a class. If I move alert to inside the function block it works. But If it stand outside the {} it doesn´t work.

class test {
    my_test() {
        var var_a = 50;
        var var_b;
        $("input[name='my_input']").click(function() {
            if ($("#radio1").is(":checked")) {
                var_b = 100;
            } else if ($("#radio2").is(":checked")) {
                var_b = 0;
            }
        });
        alert(var_b);
    }
}
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!