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 8666865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:50:09+00:00 2026-06-12T17:50:09+00:00

I have multiple links in my page rendered from the database. All of them

  • 0

I have multiple links in my page rendered from the database. All of them I gave the same ID and created an JQuery click function taking from that id. Im trying to run a simple test calling an alert but it doesn’t work. Ins’t it suppose to work? Is there a better approach?

$("#lkResumeIt").click(function () {
    alert("resume it");
});

<a id='lkResumeIt' href='#' contentID='1'>Item 1</a>
<a id='lkResumeIt' href='#' contentID='18'>Item 2</a>
<a id='lkResumeIt' href='#' contentID='22'>Item 3</a>
...

The code below using class selector workd fine when the elements are static, but when they are dynamically they dont. see actual code below:

<script language="javascript">

$("#divContent").on('click', 'a.linky', function (event) {
    alert("resume it");
});




            function RunIt() {
                $("#divContent").html("");
                var jsongo = '';
                $.ajax({
                    type: 'POST',
                    url: '/Controller/FollowingPaused/',
                    data: jsongo,
                    success: function (msg) {
                        for (i = 0; i < msg.length; i++) {
                            var htmlCode = "<a href='/Controller/Details/" + msg[i].ID + "' style = 'float: left;'><img class='packageImage' border='0' src='" + msg[i].Size0Path + "' /></a>";
                            htmlCode += "<span style='float: left;margin: 5px 0px 0px 10px;'>" + "<b>" + msg[i].TheName + "</b><br>";


                            if (msg[i].IsPaused == true) {
                                //htmlCode += "<a href='/Controller/Resume/" + msg[i].ID + "'>Resume</a>";
                                htmlCode += "<a href='#bar' class=linky contentID='" + msg[i].ID + "'>Resume</a>";
                            } else {
                                //htmlCode += "<a href='/Controller/Pause/" + msg[i].ID + "'>Pause</a>";
                                htmlCode += "<a href='#bar' class=linky contentID='" + msg[i].ID + "'>Pause</a>";
                            }
                            htmlCode += "</span>";
                            htmlCode += "<div class='clear'></div>";
                            $("#divContent").append(htmlCode);
                        }
                    }
                });
            }


RunIt() 

</script>



        <div style="display: table-row;">
            <div id="divContent" style="display: table-cell; line-height: 1.5;">
            </div>
        </div> 
  • 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-12T17:50:10+00:00Added an answer on June 12, 2026 at 5:50 pm

    IDs cannot be duplicated. If you want one hook for jQuery, use class, which CAN be duplicated.

    Example:

    HTML:

    <a href="#bar" class="linky">Foo</a>

    JavaScript:

    $("a.linky").on('click', function (event) {
        alert("resume it");
    });
    

    For dynamically-created elements:

    $("#your-static-wrapper-element").on('click', 'a.linky', function (event) {
        alert("resume it");
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a overview page containing a list with some links from which multiple
I have multiple data tables per page, ranging from 4 to 8 ish. All
I have multiple elements on page and all of them have unique id something
I have multiple links to show related contents in same page show i used
I want to delete multiple rows from my MYSQL database table. I have created
I have several dynamically created links and forms on one page named with IDs
I have multiple colorbox in one page. those colorbox's links are generated with javascript.
I've got a page with multiple links with a class of reply which have
I have this jquery: $('.tbl-link').click(function(){ $('.tbl-content').animate({ opacity: 'show', //height: '+=300px', marginTop: '330px' }, 1200).css({
I have a static page, which contains multiple links to text files on the

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.