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 is going to drive me mad, because its probably something I have missed
I probably missed something but just wanna ask.. I found this code in the
This is probably something fundamental and stupid that I've missed, but the various workarounds
It's probably late and I have missed this off by a long shot. I
Probably something really simple, but I'm having some real trouble with it. I have
Probably something simple, but heres my problem, I have implememnted a simple captcha into
I have probably missed something simple with my problem. However its like me to
This is probably a shot in the dark but here goes nothing... I have
I've probably missed something big, but I've been trying for hours... So to get
Probably a very trivial problem. I have an object that looks like this: @PersistenceCapable

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.