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

59
Views
Click on event causing change in pseudo class style

I'm trying to hack the jspsych's slider bar component. So in jspsych's source code, they have

.jspsych-slider {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  background: transparent;
}
.jspsych-slider::-webkit-slider-thumb {
  border: 1px solid #666;
  height: 24px;
  width: 15px;
  border-radius: 5px;
  background: #ffffff;
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -9px;
}

by adding the code below, I managed to achieve the effect that as soon as the slider bar is clicked, the slider bar disappears:

function(){
  document.querySelector('.jspsych-slider').addEventListener('click', function(e){e.target.style.visibility = 'hidden'})}

However, what I want to achieve is that once the slider bar is clicked, only the thumb nail (-webkit-slider-thumb) disappears. How am I supposed to do it?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You could add a class to the slider on click and then use CSS to hide the pseudo ::-webkit-slider-thumb element. Interacting with pseudo elements/selectors in JS can be a bit tedious

.jspsych-slider {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  background: transparent;
}
.jspsych-slider::-webkit-slider-thumb {
  border: 1px solid #666;
  height: 24px;
  width: 15px;
  border-radius: 5px;
  background: #ffffff;
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -9px;
}
.jspsych-slider.hidden::-webkit-slider-thumb { visibility: hidden }

function(){
  document.querySelector('.jspsych-slider').addEventListener('click', function(e){
    e.target.classList.add('hidden')
  })
}
about 4 years ago · Santiago Trujillo 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!