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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:09:57+00:00 2026-05-24T03:09:57+00:00

How can I target dynamically loaded content with jQuery? I’ve read about it a

  • 0

How can I target dynamically loaded content with jQuery? I’ve read about it a lot an found the .live() function is an easy way to add an event to loaded content, but I’m not sure how to target objects within the loaded content. I’ve got a container on the main page:

<div id="container">place to load content</div>

and a container on the loaded page:

<div id="ajax-container">
    <div id="stuff">
        <div class="random-class">stuff to be loaded</div>
        <div class="random-links"><a href="#" class="delete">delete me</a></div>
    </div>
</div>

I have a link with the class ‘delete’ that I wanted to use to delete #stuff. I found out that jQuery will ignore the newer content, and therefore I could not attach an event to that anchor. I discovered the .live() function and that fixed my click problem.

$('.delete').live('click', function() {
    alert('click event works');
    $(this).parent('#stuff').hide();
});

The alert will fire, but how can I target div#stuff as well?

  • 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-24T03:09:58+00:00Added an answer on May 24, 2026 at 3:09 am
    $('.delete').live('click', function() {
        alert('click event works');
        $(this).closest('div#stuff').hide();
    });
    

    here is the fiddle http://jsfiddle.net/5tCZH/

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

Sidebar

Related Questions

How can you change the href attribute (link target) for a hyperlink using jQuery?
I have a form generated dynamically with the method .append() of jQuery. I can
I know in Visual Studio 2008 you can target a specific framework with your
Normally we can specify a target in the link or use javascript window.open to
In MSBuild you can data drive target dependencies by passing a item group into
setTimeout(target.mousedown, 200) doesn't seem to work. I can do setTimeout(target.mousedown(), 200) , but this
When you compile windows application in .NET you can set Platform Target to be
Can the sourcecontrol block in CruiseControl.NET target TortoiseSVN?
How can I change the target of a symlink with PHP? Thanks.
Can any one please tell me the difference between target and currenttarget in flex?

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.