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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:27:43+00:00 2026-06-16T06:27:43+00:00

I need jQuery’s .on() event to fire when the page has loaded. I have

  • 0

I need jQuery’s .on() event to fire when the page has loaded. I have some dynamically generated checkboxes based on the users selections on the previous screen. I have code that does what I want it to but i’ve bound it to the ‘body’ click event to allow me to test it works.

What I have is the following and need this to trigger as soon as the page loads instead of the body click.

$('body').on('click', function (e) {
    $("input:checkbox").each(function () {
        if ($(this).attr("disabled") == "disabled") {
            $(this).parent().addClass('disabled');
        }
    });
});
  • 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-16T06:27:45+00:00Added an answer on June 16, 2026 at 6:27 am

    Two possibilities for you:

    1) Just put your script tag containing your code at the very end of the page, just before the closing </body> tag, and remove it from within an event handler:

    <script>
    $("input:checkbox").each(function () {
        if ($(this).attr("disabled") == "disabled") {
            $(this).parent().addClass('disabled');
        }
    });
    </script>
    </body>
    

    All of the checkboxes defined above the code in the HTML will be available at that point, references:

    • YUI Best Practices for Speeding Up your Website
    • Google on when DOM elements are ready

    2) Alternately, if you have some reason to put the script tag elsewhere, you can use jQuery’s ready event, which fires after the page is ready but before onload (usually):

    jQuery(function($) {
        $("input:checkbox").each(function () {
            if ($(this).attr("disabled") == "disabled") {
                $(this).parent().addClass('disabled');
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some node.js code using jsdom and I need jquery.min.js file for backend
Need some jQuery advice... I have in DOM divs with delimited entries like this:
I need some jQuery ajax help. I currently have a main content div that
I have web pages generated by JSP which sometimes also include jQuery code. Some
I need some jQuery assistance. I'm using https://github.com/jbutz/bootstrap-lightbox for my lightbox, basically what I
I need to use jquery to add and delete input fields based on user's
Using ASP.NET MVC + jQuery : I need to use some values owned by
Have a look at the following code (additionally, you will need jquery.js , jquery.viewport.js
I need some JQuery selector help... My HTML is <div id=Manager><span>LastName, FirstName (UK)</span></div> <span
I need jQuery tabs that will also work with a URL Example I have

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.