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

179
Views
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
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!