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

234
Views
How do i fix this error in next js TypeError: Cannot set properties of undefined (setting 'className')

I am working on a next js project , copied some coe on code pen , it is used for a product design of an e commerce website . However i am having this problem. TypeError: Cannot set properties of undefined (setting 'className'). What is an equalvalent of getElementsByClassName or how can i override this eror here is a glimse of the code

var slider = document.getElementsByClassName("sliderBlock_items");
    var slides = document.getElementsByClassName("sliderBlock_items__itemPhoto");
    var next = document.getElementsByClassName("sliderBlock_controls__arrowForward")[0];
    var previous = document.getElementsByClassName("sliderBlock_controls__arrowBackward")[0];
    var items = document.getElementsByClassName("sliderBlock_positionControls")[0];
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use:

document.querySelector(".your_class_name").value querySelector() can be used to select elements on a page, just pass in a CSS like selector...

Cannot set value of undefined would mean that you are trying to select HTML elements that are not on the page. This could mean your code gets run before the components get rendered

Share your full code, or add that code inside a useEffect()

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!