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

212
Views
if statement does not work - script doesn't stop when skillpoints are below 0

I have if statement that doesn't work.

I want the script to stop working when the skillpoints are 0 or below.

My code:

var skillpoints = 5;

        if (skillpoints > 0) {

            // Dodawanie skillpointów
        
            $('.str .stat-plus img').click(function() {
                var val = $('.str-img div').text();
                var new_val = parseInt($('.str-img div').text(),10) + 1 ;
                $('.str-img div').text(new_val);
                $('.str input').val(new_val);
                skillpoints--;
                $('.skillpoints').text(skillpoints);
                $('.register-skillpoints').val(skillpoints);
            });
    }

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have to put the if condition into your click handler, like this:

$('.str .stat-plus img').click(function() {
  if (skillpoints > 0) {
    // etc
  }
}

Otherwise, the if condition is checked only once at page load, and never again when clicking.

about 4 years ago · Juan Pablo Isaza Report
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!