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

90
Views
Accessing data attribute of clicked element with javascript

I have a table with payment info, and I want ability to modify contents of rows by having a "modify" button on each row. Clicking on modify, goes to a form, where user can submit content, with a paymentId associated to that row. So I need paymentId to be passed when "modify" button is clicked.

the html for this is:

//payment.entry_id is passed to the ejs template from the node server.

$('.modifyButton').on('click', e => {
  console.log("data attribute passed: ", e.target.getAttribute('data-paymentId'));
});
<button class="btn btn-warning modifyButton" data-paymentId=< %=payment.entry_id%> type="button">
  <i class="fas fa-edit"></i>
</button>

I sometimes log the correct paymentId, but sometimes it returns as null. What is the reason for this behaviour?

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!