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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:33:17+00:00 2026-05-27T05:33:17+00:00

How to create the issue: click on existing trigger links – something happens (pass)

  • 0

How to create the issue:

  1. click on existing trigger links – something happens (pass)
  2. click on the “add trigger” button, which appends a new trigger link w/ same class
  3. click on the newly created link, and it does not do the same thing as the 1st 2 links that existed from the start (fail)

Here is my example -: http://jsbin.com/equjig/3/edit

I thought the .on('click', func) function was good for adding events to current elements in the dom, but also for future elements that get added to the dom?

Here is my current javascript :

$(document).ready(function() {
  $(".link").on('click', function(e) {
    e.preventDefault();
    $("#out").append("clicked<br/>");
  });

  $("#b1").on('click', function() {
    $("#p1").append("<a href='#' class='link'>new trigger</a>");
  });

here is the HTML

<button type="button" id="b1">add trigger</button>
  <p id="p1">
    <a href="#" class="link">trigger 1</a>
    <a href="#" class="link">trigger 2</a>
  </p>
  <div id="out"></div>

Note – im using jQuery 1.7

Thanks!

  • 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-05-27T05:33:18+00:00Added an answer on May 27, 2026 at 5:33 am

    You are almost there with on …

    working example : http://jsbin.com/equjig/6/edit

    $(document).ready(function() {
        $('#p1').on('click','.link', function(e) {
            e.preventDefault();
            $("#out").append("clicked<br/>");
        });
    });
    

    This will work – you should select a parent div of the .link elements (i have used $('#p1') here, like in your jsbin)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having an issue with PyQt4. I want to create a new widget
I have an issue trying to create a dialog on event on click of
I need to create an email from which the user is supposed to click
i am implementing puzzle game application in this application create one button in click
The issue is simple really. Instead of creating folders in Visual Studio, I create
I'm trying to create a patch for cf.vim to resolve an issue with hashes.
I have ran into an interesting issue while trying to create a more usable
I've come across an issue where a web application has managed to create a
I have an issue with dynamic, runtime controls. I create a group of controls
I'm trying to create a basic shopping cart, having an issue with the product

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.