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
JavaScript: making a click event on desktop and mobile to add CSS list

I tried to add class to CSS when clicking a button and it works on desktop but it doesn't works on mobile phone

here is my code :

<script>
document.getElementById('logbit').addEventListener('click',function() {
document.getElementById('logf').classList.add('bg');

})
</script>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I do not know why you are using a jquery tag if you are not using jquery in your code.

But since you asked about jquery I will give a jquery answer.

$("#logbit").click(function() {
   $("#logf").addClass("bg");
})

That should be working on phone aswell as pc.

about 4 years ago · Juan Pablo Isaza Report

0

See if this works:

<style>
.bg {
    background-color: blue;
}
</style>
<input type="button" value="Button" id="button">
<script>
document.querySelector("#button").onclick = function () {
    document.body.classList.add("bg");
}
</script>
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!