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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:56:30+00:00 2026-06-01T19:56:30+00:00

Currently with jQuery when I need to do something when a Click occurs I

  • 0

Currently with jQuery when I need to do something when a Click occurs I will do it like this…

$(".close-box").click( function() {
    MoneyBox.closeBox();
    return false;
});

I was looking at some code someone else has on a project and they do it like this…

$(".close-box").live("click", function () {
    MoneyBox.closeBox();
    return false;
});

Notice it seems to do the same thing as far as I can tell except they are using the live() function which is now Deprecated and jQuery docs say to use on() instead but either way why use live/on() instead of my first example?

  • 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-01T19:56:31+00:00Added an answer on June 1, 2026 at 7:56 pm

    Because you might have a dynamically generated elements (for example coming from an AJAX call), you might want to have the same click handler that was previously bound to the same element selector, you then “delegate” the click event using on() with selector argument

    To demonstrate:

    http://jsfiddle.net/AJRw3/

    on() can also be synonymous with click() if you don’t have a selector specified:

    $('.elementClass').click(function() { // code 
    });
    

    is synonymous with

    $('.elementClass').on('click', function() { // code
    });
    

    In the sense that it only add the handler one time to all elements with class elementClass. If you have a new elementClass coming from, for example $('<div class="elementClass" />'), the handler won’t be bound on that new element, you need to do:

    $('#container').on('click', '.elementClass', function() { // code
    });
    

    Assuming #container is .elementClass‘s ancestor

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

Sidebar

Related Questions

I need to perform an action after a jQuery .load call, currently this is
I am currently using PHP/MySQL and the jQuery timeago plugin. Basically, I need to
I'm currently using jQuery to make a div clickable and in this div I
In jQuery I would do: var foo = jQuery(form); foo.each(function(){ this.find(.required).each(function(){...}) }) This would
I'm currently working on a bit of jQuery that will allow users to make
im working on this jquery data entry form in which i need a specific
In my learning I have always learnt and understood callbacks in jQuery like this:
I'm placing content on my page through an ajax (post) request like so: $("input#ViewMore").click(function()
Really simple question: Am I missing something? Seems like this should be all that
I have <select id=someid></select> I then click something and jquery.ajax generates new div and

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.