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

167
Views
How do I check if an id is 'active'?

I have buttons that change color when selected or when "active". Each button holds information to do calculations but when one of the buttons is pressed I need to make a box that holds one of the outputs null. I believe the easiest way to do it would be to place this in my calculations code:

if "button id" is "active"
set value to null

I do not know how to translate that english into javascript. The ids are what I am giving the CSS ".active" attribute to. Fairly new to the stack overflow thing so if this does not make sense or more information is needed please let me know. Thanks!

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

0

function myfunc(reed) {
  if (reed.classList.contains("active")) {
    document.getElementById("demon").innerHTML = "Yes I contain .active";
  } else {
    document.getElementById("demon").innerHTML = "No, sorry not having .active";
  }
}
<button class="notactive" onclick="myfunc(this)">Not active</button>
<button class="Iam active" onclick="myfunc(this)">I am active</button>
<span id="demon"></span>

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!