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

233
Views
How to target an element using multiple class names with Javascript?

I am working in Wordpress and I was able to target an element to change some of the CSS with this exact code:

body.admin-bar .mobmenu{
top:140px;
}

I need to also target this exact element with Javascript to change it's CSS properties after the user has scrolled down the page to reset it back to: top:0px

How would I target this using Javascript since it's multiple class names? I can't assign it an ID

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

0

Assuming this is the only element with this classname.

You can use the document query selector

const myElement = document.querySelector("body.admin-bar.mobmenu")

Should do the trick

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!