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

123
Views
How to have a link that has a product id in it

I am trying to make a link in a javascript render function that will come out like this on my website:

example.com/product/( product id number )

I have all my product information inside an array in a data.js file that is being accessed as for the product name that is rendering correctly buy I can't find how to make a link like shown above that changes for everyproduct (I will have 100+ products so I don't want to manually change it every time for a new product), but i cant find a way to do this, I have tried:

<a href='product/:_id'>
<a href='product/{product._id}'>

but none of these seem to work

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

0

I would suggest you to use Template literals and you are all the right track, just chance the ".

let id;
let a = document.querySelectorAll('a')
a.forEach(item=>{
item.href = `product/{id}`
id+=1
})
console.log(a)
<a ></a>
<a ></a>

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!