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

  • Home
  • SEARCH
  • 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 7715271
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:20:36+00:00 2026-06-01T02:20:36+00:00

as I read, the jquery .live() method will not be available in the future.

  • 0

as I read, the jquery .live() method will not be available in the future.
I have a function, which triggers a click for Dom inserted html:

$('.post_headl span').live( "click", function(){
            alert('###');            
});

This works fine. With .delegate() it does not work:

$('.post_headl').delegate( "span", "click", function(){
            alert('###');            
});

As I wrote above, the span and its parents are inserted by jquery. So I had to use .live().

What is the error in my .delegate() function?

I also tried this:

$(".post_headl").on("click", "span", function(event){
alert('###');

})

An had no success.

  • 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-01T02:20:37+00:00Added an answer on June 1, 2026 at 2:20 am

    You need to use a broader ancestor, such as the body. One that exists on page load and isn’t going anywhere and doesn’t get replaced or moved.

    $("body").delegate(".post_head1 span", "click", function(){...});
    

    It would be preferable to use an ancestor that is closer to the elements that fire the events. For example,

    <!-- not dynamic, never changes -->
    <div id="content> 
        <!-- the following div is dynamic and gets pulled in later -->
        <div class="post_head1"><span>click me</span></div>
    </div>
    

    you would want to use

    $("#content").delegate(".post_head1 span","click",clickHandler);
    

    or .on if currently using 1.7.1+ and no need for backward compatibility

    $("#content").on("click",".post_head1 span",clickHandler);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jquery code that uses the live method of triggering events: $(document).ready(function()
I have read the documentation of each function on jQuery official website , but
I have read jQuery Event Keypress: Which key was pressed? and How can i
I read your reply regarding the jQuery validator where you outline a method to
I have read a lot about jquery and i have a simple webservice that
I have read this. Jquery checkbox <input type=checkbox name=checkGroup id=all> <input type=checkbox name=checkGroup id=one
I've read jquery fundamentals which appears a popular recommendation for starting o jquery. I'm
I need some assistance with some javascript/jquery I have put in place. The function
A website in C# and jQuery will read the last post from a Twitter
I am using jQuery 1.7.1 on my site and using the .live() function for

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.