Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

150
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda