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

149
Views
can .on('click') be used to add to a number value?

I want my .on('click') function to add one to my number value every time the Html button is clicked. I can't find anywhere that has helped me and I have spent a long time looking and nothing helps. I have tried the basic numbers and math variables. but since I'm brand new to javascript I don't know where I'm going wrong

import 'bootstrap@4.6.0'
import $ from 'jquery'
const number = {
  number:0  
};
$('button')
  .html('Click me') // Try edit it...
  .on('click') 
body {
  height: 100vh;
} 
<div class="d-flex h-100">
  <button class="btn btn-warning m-auto">
    Hi! Click me
  </button>
</div>

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

0

<div class="d-flex h-100">
        <button class="btn btn-warning m-auto">
          Hi! Click me
        </button>
        <p id="result"></p>
      </div>

Here is Plain Javascript

const addNum = document.querySelector('.btn');
let num = 0;
addNum.addEventListener('click', () =>{
    let result = document.querySelector('#result');
    result.innerHTML =num++;
});

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!