Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7940801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:28:52+00:00 2026-06-03T23:28:52+00:00

This looks very simple but I have little experience with jQuery and I can’t

  • 0

This looks very simple but I have little experience with jQuery and I can’t wrap my head around it.

Let’s say I have a dynamically generated HTML table, and in each row of this table is a link:

<a id='edit'>Edit User</a>

Now, the link should call a function with each user’s ID as a parameter. I could do that inline liek this:

<a id='edit' onClick='editUser(<?php echo $row['id']; ?>)'>Edit User</a>

But how do I do this in jQuery?

I can call the function like this:

$('a#edit').click(function () {
      editUser()
      return false;
    });

But how do I pass the ID to this function? I know I could first stick it into a hidden field and then get it from there by element id, but surely there’s a better way?

I realize all the links would have the same id this way, so should I dynamically create the link ids by appending the user id? But then how do I call the jQuery?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:28:53+00:00Added an answer on June 3, 2026 at 11:28 pm

    ids must be unique throughout the entire HTML. So you could use a class selector and HTML5 data-* attribute:

    <a class="edit" data-id="<?php echo $row['id']; ?>">Edit User</a>
    

    and then:

    $('a.edit').click(function () {
        var id = $(this).data('id');
        // do something with the id
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a very simple PrototypeJS class that looks like this: var
I have very little experience with AWK, but it seems like the best tool
I have very little experience in web development, so this may be a very
I'm trying to use this library (which looks very nice) but I'm having difficulty
I have a string that looks like this: <name>-<gender>-<age>.jpg I want to be very
Probably a very trivial problem. I have an object that looks like this: @PersistenceCapable
This looks simple but I am confused: The way I create a vector of
This may be something very easy but i can't seem to get this to
This probably has a very simple answer, but I'm having trouble figuring it out...
This pattern pops up a lot. It looks like a very verbose way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.