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

160
Views
Why I am getting undefined on web page?

I am trying to display user status in the Gantt chart. But it returns undefined.

In this picture it is returning undefined and something else

.

I am using this method to return output

 var stat = groups.push(document.getElementsByClassName('status')); 
 var st = document.write(stat);

But it shows undefined and some server data instead of displaying 'Active' or 'Pause'

function userStatus(online) {
  const element = document.querySelector('.status');
  if (online) {
    element.classList.remove('offline');
    element.classList.add('online');
    element.innerText = 'Activ';
  } else {
    element.classList.remove('online');
    element.classList.add('offline');
    element.innerText = 'Pause';
  }
}
window.addEventListener('load', () => {
  userStatus(navigator.onLine);
  window.addEventListener('online', () => {
    userStatus(true);
  });
  window.addEventListener('offline', () => {
    userStatus(false);
  });
});
.app {
  height: 4.7vh;
  width: 4.7vw;
  display: flex;
  align-items: center;
  background-color: #000000;
  margin-left: 0.4px;
}

.status {
  margin-left: 10px;
  font-size: 15px;
  width: 2.5%;
}

.status.online {
  color: #41a700;
}

.status.offline {
  color: #f15c4f;
}

.app {
  margin-left: 261px;
}

.app {
  position: relative;
  margin-bottom: 5%;
}
<div class="app">
  <h5 class="status">User Status</h5>
</div>

about 4 years ago · Juan Pablo Isaza
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!