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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:28:23+00:00 2026-05-26T20:28:23+00:00

Real Dumb question. I figured I would have gotten this straight by now, but

  • 0

Real Dumb question. I figured I would have gotten this straight by now, but I am obviously missing something. I want my function to fire as soon as the page loads to check the value of a variable and make a button appear or dissapear based on that value. But the function I wrote never gets called. I place the function inside a $.Load() and $(document).ready jquery call. How can I get this function to fire?

 $(document).ready(function () {
        debugger;        
        (function () {           
        debugger;
        var $b = '<%=toggle %>';
        var buttonTog = $("#test1");
        var buttonTog1 = $("#Submit1");
        if($b=="1")
        {
            debugger;
            buttonTog1.css({
                display: 'block'
            })
            buttonTog.css({
                display: 'none'
            });
        }
        else if($b=="0")
        {
            debugger;
            buttonTog1.css({
                display: 'none'
            })
            buttonTog.css({
                display: 'block'
            });
           }            
       });
       ...
    });

As you can see, I have multiple debugger statements in there that just don’t get hit… When I hit $(document).ready and I get into the first debugger statement, It simply doesn’t touch the next function? I don’t get it? It goes right over it? Can you not call a function inside the .ready(function())? Definitly need to get some research done.

  • 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-26T20:28:24+00:00Added an answer on May 26, 2026 at 8:28 pm

    You define an anonymous function but you never call it. Here’s how to auto-invoke the anonymous function:

    $(document).ready(function () {
        (function() {
            var buttonTog = $("#test1");
            var buttonTog1 = $("#Submit1");
            ...
        })(); // <!-- notice the (); at the end
    });
    

    This being said, I can hardly see the usefulness of using this anonymous auto-invoking function inside the document.ready callback which itself is an anonymous function. Things start to get really private here 🙂

    You could simply write the code inside it:

    $(document).ready(function () {
        var buttonTog = $("#test1");
        var buttonTog1 = $("#Submit1");
        ...
    });
    

    I suspect that you might be missing some important concepts about the $(document).ready function and its syntax. I would recommend you checking the documentation for more examples.

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

Sidebar

Related Questions

am sorry for this dumb beginner question, but i have a real problem understanding
This could be a dumb question, but I have submitted a few apps where
This is really weird and I fear I have just done something dumb but
Real noob question no doubt, but I can't get my head around this behaviour.
Ok, I'me getting real dumb with this one.... I have this class: Public Class
I feel pretty dumb at the moment, but for several days now, I have
real newbie question but why doesn't this work? I am getting use of unassigned
In my real website I have actual content but this example should suffice. LOGO
This must be a real dumb question. And I cant figure out how. What
A real F# noob question, but what is |> called and what does it

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.