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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:27:11+00:00 2026-06-18T09:27:11+00:00

What is the difference between the calling of jquery functions using on and after

  • 0

What is the difference between the calling of jquery functions using on and after find using on

<div class="outer">
    <span>One</span>
    <div class="inner"><button id="button">button 1</button></div>
</div>
<div class="outer">
    <span>Two</span>
    <div class="inner"><button id="button">button 2</button></div>
</div>

The jquery code is

$(document).ready(function(){

    $('div.outer').on('click',".inner #button",function(event){
        console.log(this);//this works
    });
    $('div.outer').find(".inner #button").on("click",function(event){
        console.log(this);//this works
    });
    $('div.outer').find(".outer span").on('click',function(event){
        console.log(this);//this not works
    });
});

Here it is a simple example I am creating a jquery plugin which has multiple instances so each button clicked twice. I used jquery.off before bind each function, but it not works.

  • 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-18T09:27:12+00:00Added an answer on June 18, 2026 at 9:27 am

    The first one is a dynamic event handler, it binds the event to div.outer, a parent of #button, but filters based on the #button selector, that way it works even if the element is not present at the time the event is bound, i.e. dynamically insterted elements.

    The two last ones are regular event handlers, and find() just finds an element within another element, so in the middle one it searches for #button within .inner within .outer, and attaches a regular event handler to #button.

    As ID’s are unique, it’s really uneccssary to use find that way, as just $('#button').on() should be enough.

    In the last one the click is bound to the span, and not the button, so any click on the button will not fire the event, but clicking on the span will.

    EDIT:

    Your selector searches for .outer inside .outer, that’s why it’s not working, you should be searching for just a span inside .outer, so this:

    $('div.outer').find(".outer span")
    

    should be this:

    $('div.outer').find("span")
    

    FIDDLE

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

Sidebar

Related Questions

What is the difference between: jQuery('tr').after('<tr><td rowspan=4>value</td></tr>') and calling this 4 times jQuery('tr').after('<tr><td>value</td></tr>') I
Can someone explain the difference between using a $ when defining variables in jQuery
Please what is the difference between using jquery .bind() to attach an event to
What is the difference between using a Web Service and calling a server page
What is the difference between calling boost::asio::ip::tcp::socket 's read_some / write_some member functions and
What's the difference between calling .NET methods asynchronously by using: BeginInvoke/EndInvoke vs. IAsynchResult vs.
Possible Duplicate: What’s the difference between calling MyClass.class and MyClass.getClass() Wanting to have a
What's the difference between calling a method through an object vs a class. for
I have one clarification What is the difference between calling a function through function
Is there any difference between calling len([1,2,3]) or [1,2,3].__len__() ? If there is no

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.