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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:49:28+00:00 2026-05-27T23:49:28+00:00

Are the docs for jQuery’s on() function incorrect (or unclear)? Consider this code: <div>

  • 0

Are the docs for jQuery’s on() function incorrect (or unclear)? Consider this code:

<div>
    <span>
        <div>
            <input type="button" value="click me!" />
        </div>
    </span>
</div>

$(document).on("click", function() {
    console.log(this.toString());
});

The docs state

selector A selector string to filter the descendants of the selected
elements that trigger the event. If the selector is null or omitted,
the event is always triggered when it reaches the selected element.

Clicking the button only causes one console.log for the document itself, while $(document).on("click", "*", function()... causes many.

I know the Stack Overflow community isn’t responsible for the jQuery docs, but shouldn’t they say that when the selector is omitted, the event is only triggered when it reaches the selected element? Or is there something about event delegation I’m not understanding correctly?

Complete fiddle

  • 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-27T23:49:29+00:00Added an answer on May 27, 2026 at 11:49 pm

    There is no event delegation when you leave the selector out. From the docs:

    If selector is omitted or is null, the event handler is referred to as
    direct or directly-bound. The handler is called every time an event
    occurs on the selected elements, whether it occurs directly on the
    element or bubbles from a descendant (inner) element.

    When a selector is provided, the event handler is referred to as
    delegated. The handler is not called when the event occurs directly on
    the bound element, but only for descendants (inner elements) that
    match the selector. jQuery bubbles the event from the event target up
    to the element where the handler is attached (i.e., innermost to
    outermost element) and runs the handler for any elements along that
    path matching the selector.

    Basically .on is doing the jQuery thing — it is overloaded to do completely different things depending on arguments. Personally I prefer .delegate for delegation, and .bind for normal events, as they are much clearer and I hope they don’t get removed in later versions.

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

Sidebar

Related Questions

I have tried to implement this jQuery active menu code: http://docs.jquery.com/Tutorials:Auto-Selecting_Navigation $(function(){ var path
I am trying to select all my textboxes with... $(input[@type=text]) From the jquery docs
I'm using this: http://docs.jquery.com/UI/Autocomplete I'm initializing a text box like this (partial code): $('#foo').autocomplete
I'm trying to use the autocomplete plugin for jQuery (this one http://docs.jquery.com/Plugins/Autocomplete ). My
The docs for Dictionary.TryGetValue say: When this method returns, [the value argument] contains the
I'm using this dialog: http://docs.jquery.com/UI/Dialog To open dialog I do it this way: $('a.openModal').live(click,
I am using this and it's working perfectly on the browser http://docs.jquery.com/UI/Sortable Now I
I am using this jQuery form validation plugin: http://docs.jquery.com/Plugins/Validation/Methods I am trying to use
I'm using this jQuery Tooltip plugin: http://docs.jquery.com/Plugins/Tooltip I create tooltips for all links when
I am using the $.grep() function http://docs.jquery.com/Utilities/jQuery.grep $.each($.grep( [0,1,2], function(n,i){ return n > 1;

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.