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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:22:02+00:00 2026-06-14T17:22:02+00:00

In my code I am binding event handlers to document : $(document).bind(myEvent, function() {

  • 0

In my code I am binding event handlers to document:

$(document).bind("myEvent", function() { ... });

Do I have to wait for the ready event (i.e. use $(document).ready) to bind event handlers in general and when I bind them to document in particular?

  • 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-14T17:22:03+00:00Added an answer on June 14, 2026 at 5:22 pm

    $(document).ready is used to ensure the DOM is ready before trying to interact with it. If you put your script in the <head> then I suggest you put your code within this block if you interact with the DOM. If you put your script at the bottom of the <body> after the DOM elements then its not required – but I would still suggest its used.

    Update

    Attaching an event handler to the document doesn’t require the code to be within the ready handler but its often used for consistency, some people (me included) place all script to attach event handers (regardless of the target) in a ready handler.

    You will notice that on the documentation for bind() that elements must exist before the handler is attached.

    Handlers are attached to the currently selected elements in the jQuery object, so those elements must exist at the point the call to .bind() occurs.

    Also note that .on() is the preferred and suggested method to use inplace of .bind() as of jQuery 1.7

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

Sidebar

Related Questions

I have jQuery code that handles unbinding and binding event handlers to elements that
I have the following jQuery code on a site I built: $(document).ready(function() { //
I am using the folowing code (located in file swipe.js): $(document).ready(function() { $('.ui-slider-handle').live('touchstart', function(){
When binding code to the execution of an event using mxml, by assigning the
How do I use data-binding from code (C# or VB)? This is what I
I have tried for unload and beforeunload binding in following code, but none of
I have a code snippet as below <CheckBox Name=cb Margin=1,2,1,0 IsChecked={Binding Path=IsManager} IsEnabled=True/> Consider
I have the following markup / code block in the ASPX file. The binding
The document.ready is used to execute code after the DOM is fully loaded. This
I note that it's recommended to use named functions when binding an event handler

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.