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

204
Views
Intentando que el HTML se muestre para cambiar cada vez que se hace clic en un nuevo botón con jquery
let table = 6; let i = 1; $(function() { let $newOperatorButton = $('button'); $newOperatorButton.on('click', function math(){ let msgOperator = ''; let expression; let operator = $(this).attr("value"); if(operator === '+'){ msgOperator = ' + '; expression = (table + i); while(i < 11){ msg += table + msgOperator + i + ' = ' + (table + i) + '<br />'; i++; } } else if (operator === '-') { msgOperator = ' - '; expression = (table - i); while(i < 11){ msg += table + msgOperator + i + ' = ' + (table - i) + '<br />'; i++; }

falta algo de código pero agrega multiplicación y división

 let el = document.getElementById('blackboard'); el.innerHTML = msg; } ); });

Este código está dentro de la etiqueta del cuerpo en mi index.html

 <section id="page"> <section id="blackboard"></section> </section> <form id="operator"> <button name="add" type="button" value="+">+</button> <button name="subtract" type="button" value="-">-</button> <button name="multiply" type="button" value="x">x</button> <button name="division" type="button" value="/">/</button> </form> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> <script src="/index.js"></script>

Lo tengo, por lo que imprime una tabla con 10 números según el botón en el que se hizo clic. por ej. tabla = 6 y i = 1 es 6+1=7.... 6+10=16

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

0

Necesita una declaración if al final que restablezca sus ecuaciones y variables.

después de ejecutar su ecuación, "i" sigue siendo igual a 11, por lo que nunca vuelve a pasar a los bucles while, también debe vaciar su mensaje para que no siga agregando texto adicional a su texto existente.

 $("#blackboard").html(msg) if (i == 11) { i = 1 msg = "" }
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!