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

180
Vistas
Javascript passing object set in data attribute to a function seem not working

I am developing a gallery site with Reactjs and want to pass multiple values in object format to a function as parameter when onclick.
But when I console the param in function, the value showing "[object object]".

enter image description here

Here is the code

<button onClick={handleToggleModal} data={{ id: value.tempid, demoUrl: value.demolink }}>More Info</button>

for the function

function handleToggleModal(e) {
  let arr = {};
  arr.push(e.currentTarget.getAttribute("data"));  
  console.log(e.currentTarget.getAttribute("data"));  // Showing [object object] in console
}  

Seem this is not working to use html attribute to pass object or array. Searched online but not able to find the question similar to this. Thanks for the help in advanced.

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