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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:26:16+00:00 2026-05-15T06:26:16+00:00

Probably I missed something, but lets say I have this: $(‘a.delete’).click(function(){ resp=window.confirm(Are you sure

  • 0

Probably I missed something, but lets say I have this:

$('a.delete').click(function(){
   resp=window.confirm("Are you sure you want to delete this?");
   if(resp)
       return true;
   else
       return false;
}

Now, I want to save that callback function into a separate js file, because I will use it in several pages. My logic told me to do this:

$('a.del').click(delete_element());

Having my js file like this:

function delete_element(){
   resp=window.confirm("Are you sure you want to delete this?");
   if(resp)
       return true;
   else
       return false;
}

This doesn’t work. Everytime my page loads, it displays the confirm window, even if I haven’t clicked the link.

It is clear that my logic failed this time. What am I missing?

  • 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-15T06:26:17+00:00Added an answer on May 15, 2026 at 6:26 am

    $(‘a.del’).click(delete_element());

    That is calling the function delete_element() and hoping for a function to be returned.

    $('a.del').click(delete_element);
    

    That (note the missing ()) will set the click handler to delete_element.

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

Sidebar

Related Questions

This probably has a simple answer, but I must not have had enough coffee
This probably sounds really stupid but I have noo idea how to implement jquery's
Probably a long question for a simple solution, but here goes... I have a
This is probably going to be a no, but is there any way I
I probably missed something in the .tt configuration for some reason my intellisense when
Probably a really simple one this - I'm starting out with C# and need
This question would probably apply equally as well to other languages with C-like multi-line
As many of you probably know, online banks nowadays have a security system whereby
Probably an easy one: Are there any rules of thumb or pointers that could
Probably not much more to elaborate on here - I'm using a NumericStepper control

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.