• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

175
Views
Parcel.js javascript problem when adding attributes to img element

Parcel.js can't figure out what is the path when it reads .js file.

code:

 image.setAttribute("src", `../images/icon-${el}.svg`)

result:

enter image description here

almost 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

import rockImage from "../images/icon-rock.svg"
import paperImage from "../images/icon-paper.svg"
import scissorsImage from "../images/icon-scissors.svg"

let img = document.createElement("img")
img.src = rockImage

Firstly import the images with "Import", and then append it to the newly created "img" element.

almost 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error