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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:02:46+00:00 2026-06-08T04:02:46+00:00

Lately when binding click events in jQuery I find myself questioning whether to use

  • 0

Lately when binding click events in jQuery I find myself questioning whether to use the jQuery shortcut click() or if I should specify the .on('click', ...) call myself.

The .click(). function in jQuery is just a shortcut. To me it makes sense to use because jQuery handles everything behind the scenes accounting for the preferred method per the version of jQuery being used. When I upgraded my scripts from jQuery 1.6 -> 1.7 I know that all of my click()s went from being a shortcut to bind() to the preferred on() method. This, alone, seems reason enough to use the shortcuts.

…however….

Trevor Burnham, whom I greatly respect, says in his eBook Async Javascript that he

… prefer(s) to consistently use the more powerful bind/on) (over click)

That confuses me and I was wondering why using bind/on is ‘more powerful’.

What have you found to be the best practices when binding events that have shortcuts in jQuery? Use the shortcut or do it yourself?

  • 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-08T04:02:48+00:00Added an answer on June 8, 2026 at 4:02 am

    I think it has to do with personal preference and code readability more than anything.

    As far a more powerful goes .on lets you delegate events while shortcuts always operate on the element directly. For example $('body').on('click', '.button', function(){}); will work for every .button element even those added after the fact with ajax or otherwise. While the shortcut cannot do this $('.button').click(function(){}); is the only way to add a listener to .button and does not feature delegation, so .button elements added later will not have this binding.

    Direct un-delegated events (like shortcuts) on multiple elements is also slightly less efficient then delegated events on a parent object. For example: lets say there are 15 .button elements on the page, $('.button').click(... will loop through all 15 elements and add an event listener to each; however $('#parentElem').on('click', '.button', ... will simply attach a single event listener to #parentElem that checks on the target, so one attach and one listener, vs a loop and 15 listeners.

    And finally, .on has the advantage of allowing you to attach a function to an element from multiple events, which is not possible with shortcuts, for example: $('.button').on('click mouseover keyup', ... the function will trigger with click, mouseover or keyup!


    Lets again say there are 15 .button elements in a div called #parent

    Shortcut handler:

     $('.button').click(turnRed);
     $('.button').mouseover(turnRed);
     $('.button').keyup(turnRed);
    
     function turnRed(){
          $(this).css('color','red');
     }
    
    • 4 jQuery objects created (yes I know you could cache it to 2 objects but this is an example)
    • 3 element loops of 15 each, so jQuery hits elements here 45 times and attaches listeners
    • 45 total event listeners
    • future .button elements added to the scene do not turnRed

    .on handler:

     $('#parent').on('click mouseover keyup', '.button', turnRed);
    
     function turnRed(){
          $(this).css('color','red');
     }
    
    • 2 jQuery objects created
    • No element loop, so jQuery hits elements once
    • 3 total event listeners
    • future .button elements add to the scene will in fact turnRed

    Here .on clearly has the advantage


    If your situation is simpler than this, then the advantage of .on may not make a difference to you, and the shortcut may be preferred as its more readable.

    $('#button').click(... is nearly identical to $('#button').on('click', ... (see @Fabrício Matté’s answer) and if we just want to add one listener to one event, the .on‘s power is a moot point.

    Personally because there are times when I want the advantage of .on I always use .on just to be consistent.

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

Sidebar

Related Questions

Lately, I've often found myself wanting to run some command on the output of
I've found myself using the following idiom lately in clojure code. (def *some-global-var* (ref
Lately, I've been wondering how to find the difference between two files with PHP.
Lately I've been considering creating a sort of toolbox for myself in java. It
I have lately read several articles and questions about Model Binding and Validation in
I've been doing some Web-Projects lately that rely on heavy Data-Binding and have been
Lately I've found myself constantly running ILDASM to study the MSIL output of my
Lately, I've had lots of trouble with __repr__() , format() , and encodings. Should
Lately I'm interested in the topic of genetic algorithms, but I couldn't find any
Lately I bumped repeatedly into the concept of LFSR, that I find quite interesting

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.