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

The Archive Base Latest Questions

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

I have a button that i what to be clicked automatically after the page

  • 0

I have a button that i what to be clicked automatically after the page is loaded. I used setTimeout but it does not seem to work. What is wrong? it worked in other similar posts in stackoverflow which is where i got the idea from but for some unknown reason to me in does not work in my code

    $(document).ready(function() {
                    jQuery(function($){
                        // The variable jcrop_api will hold a reference to the
                        // Jcrop API once Jcrop is instantiated.
                        var jcrop_api;

                        initJcrop();

                        // The function is pretty simple
                        function initJcrop()//{{{
                        {

                          // Invoke Jcrop in typical fashion
                          $('#target').Jcrop({
                            onRelease: releaseCheck,

                          },function(){

                            jcrop_api = this;
                            // Setup and dipslay the interface for "enabled"
                            $('#can_move').attr('checked','checked');

                          });

                        };
                        function releaseCheck()
                        {
                          jcrop_api.setOptions({ allowSelect: true });
                          $('#can_click').attr('checked',false);
                        };



                        $('#setSelect').click(function(e) {
                          // Sets a random selection
                          jcrop_api.setSelect([0,0,400,118]);
                        });

                      });
         setTimeout(function() {
            $('#setSelect').trigger('click');
        },10);
    });

<button id="setSelect">setSelect</button>
  • 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-18T08:52:12+00:00Added an answer on June 18, 2026 at 8:52 am

    There might be an issue with asynchronous order of things:

    eg. the setTimeout is popped before the click handler is set, or maybe after the click handler is set but before the jcrop_api is set. Note that just because one line is below the other doesn’t mean it is executed later – because you don’t control when the callback that initializes jcrop_api is called.

    Adding console.log lines may be useful to debug this problem and see if the code is executed in the order you plan.

    To fix the order of things you can set up the click handler only after you initialize the jcrop_api, and set the timeout only after the click handler is set up (maybe you don’t need a timeout at all then).

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

Sidebar

Related Questions

I have a web page that has a button that when clicked will download
I have a button set up that when clicked, expands the page. Here is
I have a button that when clicked will run a stored procedure on a
In my Silverlight UI, I have a button that when clicked pops up a
In my Delphi Project i want to have a 'Settings' button that when clicked,
I have a button that opens a dialog when clicked. The dialog displays a
I have a button in my XML, that when clicked will toggle the visibility
I have a usercontrol that hides a div when a button is clicked. <asp:LinkButton
I have a link that changes text every time its clicked but I am
I have a button that when clicked displays some information, can i manually trigger

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.