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

343
Views
Adding a class (related to tailwind) using javascript doens't work

I have a button with a PLUS svg image in it. On click, I what that Plus svg to disappear. I checked in console and the function works fine, the class "visible" is removed and the class "invisible" is added. But in the UI the Plus svg doesn't disappear. "Invisible" is a class in Tailwind that should make an item to be hidden.

const BtnAddEle = document.querySelector(".addEle");
const plusSvg = document.querySelector(".addElePlus");

BtnAddEle.addEventListener("click", function () {
  plusSvg.classList.remove("visible");
  plusSvg.classList.add("invisible");
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is happening because tailwind only adds class styles which you have used in the final CSS file

So you can do something like this

const BtnAddEle = document.querySelector(".addEle");
const plusSvg = document.querySelector(".addElePlus");

BtnAddEle.addEventListener("click", function () {
  plusSvg.style.visibility = "hidden"
});
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!