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

133
Views
How can I avoid decimals in a number value that is shown with innerHTML

The code is for an audio system when the user presses Up arrow or Down arrow then the volume changing with 0.05 up or down (5%) on the audio volume. That code isn't important. I just said because the changing value is 0.05 that means when I want to display the current volume the numbers sometimes look like this:
A good one:
A bad one:

Anything I could use? Maybe RegEx? (but how) Here is the code:

Element.innerHTML = "Hangerő: <strong>" + (audio_element.volume * 100) + "%</strong>"
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try parseInt() .

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt

Element.innerHTML = "Hangerő: <strong>" + parseInt(audio_element.volume * 100) + "%</strong>"
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!