Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

131
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda