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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:22:45+00:00 2026-05-28T04:22:45+00:00

This works just fine in jQuery 1.6.4 for dynamic html: $(.selector).die().live(click, function () {

  • 0

This works just fine in jQuery 1.6.4 for dynamic html:

$(".selector").die().live("click", function () {
    alert("clicked");
});

but I noticed in jQuery 1.7.1 that .live() is deprecated and replaced by .on(). How can I use .on() with dynamic html? Using .die().on("click", function()) doesn’t work and neither does .off().on("click", function()).

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-28T04:22:46+00:00Added an answer on May 28, 2026 at 4:22 am

    The new on method works in much the same way that delegate did in older versions of jQuery. You need to use it on an ancestor element and supply a selector. Since DOM events bubble up from the target, they will eventually reach the ancestor element you have used on on. When the event reaches that element, the target is checked to see if it matches your selector. If so, the event handler is executed:

    $("#someAncestor").on("click", ".selector", function() {
        //Do stuff
    });
    

    There has been no need to use live since delegate was added, some time around version 1.4. Using delegate the above snippet would be:

    $("#someAncestor").delegate(".selector", "click", function() {
        //Do stuff
    });
    

    delegate and on are far more efficient than live, since live always binds event handlers to the document. That means every single event triggered on the page has to be tested to see if it matches the selector and should therefore cause an event handler to run. With on, only events that bubble to the ancestor element will require this check.

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

Sidebar

Related Questions

Well, I am using this jquery carousel plugin ...and it works just fine (it
$('#search_form').submit(function(e) { //e.preventDefault(); return false; }) This works just fine to prevent form submission
this code in my plugin used to work just fine: jQuery('#embedded_obj', context).get(0).getVersion(); and the
This works just fine: protected void txtTest_Load(object sender, EventArgs e) { if (sender is
I have a Firefox 3.6.2 problem (3.5.x works just fine). This is the code:
I want to port this SQL query, which works just fine on SQL Server,
I've got a problem with this embed in Safari. It works just fine on
when I run this JS in FF or Safari it works just right but
Not sure if I've just missed something but this doesn't work: $(this).children('td.threadtitle a').html('thread title');
I'm calling a page method with jquery and it works just fine. I'm creating

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.