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

118
Views
Add url from HTMLCollection with Javascript

I'm trying to display images on click. Those images have urls that I get from an HTMLCollection. I need to add 2 divs containing different classes, I managed to do it but I can't get the url to display my images on click. Please can someone help me ?

const image = document.querySelector('.slider-image');

image.addEventListener("click", () => {

document.getElementById("modal").classList.remove('hidden')
// Get urls (display gallery items)

let urls = image.getElementsByClassName('gallery-url');

  for (let i=0; i<urls.lenght; i++) {
    const getDivSliderCtn = document.getElementsByClassName("slider-container");
    let div = document.createElement('div');
    div.classList.add('slider-image');
    let bckgImage = div.style.backgroundImage=`url(${urls})`;
    div.appendChild(bckgImage);
    getDivSliderCtn +=urls[i];

}

about 4 years ago · Juan Pablo Isaza
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!