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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:09:38+00:00 2026-05-15T14:09:38+00:00

$(document).ready(SetupButtonClicks()); function SetupButtonClicks() { $(‘#btnJavaPHP’).click(DoPHPStuff()); } function DoPHPStuff() { //stuff } I have this

  • 0
$(document).ready(SetupButtonClicks());

function SetupButtonClicks() {
    $('#btnJavaPHP').click(DoPHPStuff());
}

function DoPHPStuff() {
    //stuff
}

I have this code in my javascript file, when I debug it I see it call SetupButtonClicks() like it should but after that is done it calls DoPHPStuff(). DoPHPStuff() should only be called when btnJavaPHP is clicked. What am I doing wrong?

  • 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-15T14:09:39+00:00Added an answer on May 15, 2026 at 2:09 pm

    Change your SetupButtonClicks function:

    $('#btnJavaPHP').click(DoHPStuff);
    

    The way you’ve got it coded, you’re telling Javascript to call the function, not to use it as the “click” handler. The parentheses are an operator that causes a function to be called.

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

Sidebar

Related Questions

$(document).ready(function(){$([href]).appendTo( Click here ...);}); HTML Code <a href=#> b </a> I want to to
$('document').ready(function(){ $('[name=mycheckbox]').live('click', function(){ if($(this).is(':checked')) { alert('it is checked'); } else { alert('it is not
$(document).ready(function() { $(#register button[name=btnPosta]).click(function() { console.log('clicked'); thisBtn = $(this); parent = $(this).parent(); name =
$(document).ready(function() { $(#register button[name=btnPosta]).click(function() { console.log('clicked'); thisBtn = $(this); parent = $(this).parent(); name =
$(document).ready(function(){ $(#CO_createAccount).click( function (){ if(this.checked){ $(.CO_accountForm).show(); } else { $(.CO_accountForm).hide(); } }); }); and
$(document).ready(function() { $(span.link).mouseover(function(e){ $(this.children).css(display,inline); }); }); I'm not a javascript expert, but I've cobbled
$(document).ready(function() { $('#comment textarea').click(function() { if (this.value == this.'Post a comment') { this.value =
$(document).ready(function() { $(tr).removeClass(); $(tr:gt(0)).click(function() { $(this).css(color, red) }); }); .highlight td { background: red;
$(document).ready(function(){ $(a).click(function() { $(#content).load($(this).attr(href)); window.location.hash = $(this).attr(href); return false; }); }); So I use
$(document).ready(function(){ $('#button').click(function(){ $('.accordion').load('<iframe src=google.com frameborder=0 scrolling=no id=myFrame></iframe>'); }); }); This can't display the iframe

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.