NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io


Stack Overflow

About
Products
For Teams

Join Stack Overflow to learn, share knowledge, and build your career.

Home
Public

Questions
Tags
Users
Find a Job
Jobs
Companies

Teams
Stack Overflow for Teams – Collaborate and share knowledge with a private group.

Are you sure you want to delete?
Asked 11 years, 4 months ago
Active 11 years, 4 months ago
Viewed 22k times
9
2

I just wrote a confirm delete function that requires a class name:

jQuery(document).ready(function($) {
$('.ConfirmDelete').click(function() {
var question = $(this).attr('title');
if (question == '') question = 'Delete this record?';
return confirm(question);
});
});

Usage:

<input name="Delete" type="submit" value="Delete" class="ConfirmDelete" title="Delete #UsrName#?" />

I'd like to change the selector from .ConfirmDelete to something like:

$('input:submit').attr('name','Delete').val('Delete')

Meaning: If a submit button has the name 'Delete' and it's value is 'Delete', then go ahead and assume they want to confirm the delete without requiring them to have a ConfirmDelete class.
jquery
Share
Follow
asked Jan 1 '10 at 20:40
Phillip Senn
43k8383 gold badges242242 silver badges359359 bronze badges

You could use an html5 data tag, data-delete="true", then use jQuery to find them. – ShiftyThomas Jan 11 '13 at 14:07
Nah. Anytime it's a submit button with the name of "delete" with a value of "delete", I want it to confirm "Are you sure" before submitting the form. – Phillip Senn Jan 11 '13 at 16:22

Add a comment
4 Answers
14

$(':submit[name="Delete"][value="Delete"]').click(function() {
return window.confirm(this.title || 'Delete this record?');
});

Share
Follow
answered Jan 1 '10 at 20:58
David Hellsing
97.2k4040 gold badges163163 silver badges203203 bronze badges

This answer was written in 2010. I would use $('form').on('click','input:submit[name=Delete][value="Delete"]',function() {}) now. – Phillip Senn Jan 11 '13 at 16:24
2
As in your Company? Well ok, but that doesn’t necessarily apply to everyone... so it’s not a very helpful addition to the answer IMO. – David Hellsing Jan 12 '13 at 10:43

Add a comment
6

The following would apply to all present, and future instances of any submit button having both the name and value of "Delete":

$(function(){

$(":submit[name='Delete'][value='Delete']").live("click", function(e){
e.preventDefault(); // remove if not necessary
// Seriously, delete it.
});

});

Share
Follow
answered Jan 1 '10 at 20:44
Sampson
252k7070 gold badges517517 silver badges549549 bronze badges

Jonathan, you bring up a good point using the live method. Back in 2010 that was an excellent point. Q: Does the "on" method use event delegation? – Phillip Senn Mar 8 '12 at 0:54

Add a comment
1

Something like this maybe?

$('input:submit[name="Delete"][value="Delete"]')

Share
Follow
answered Jan 1 '10 at 20:44
Mickel
6,55855 gold badges3939 silver badges5959 bronze badges
Add a comment
1

Your question is a bit vague, but if I interpret it correctly, you actually want to know the syntax to select a input type="submit" name="Delete" value="Delete" in jQuery?

If so, here it is:

$('input:submit[name="Delete"][value="Delete"]')

Share
Follow
answered Jan 1 '10 at 20:44
BalusC
992k351351 gold badges34783478 silver badges34503450 bronze badges

A bit vague? My goodness I don't know how much more I could have put into the question without going on and on! – Phillip Senn Jan 2 '10 at 4:30
The topic title did in no way cover the actual problem/question. – BalusC Jan 2 '10 at 6:58

Add a comment
Your Answer

Sign up or log in
Post as a guest
Name
Email

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy
Not the answer you're looking for? Browse other questions tagged jquery or ask your own question.

The Overflow Blog

Using Kubernetes to rethink your system architecture and ease technical debt

Level Up: Linear Regression in Python – Part 1
Featured on Meta
Testing three-vote close and reopen on 13 network sites
The future of Community Promotion, Open Source, and Hot Network Questions Ads
Outdated Accepted Answers: flagging exercise has begun

Related
1139
How do you remove all the options of a select box and then add one option and select it with jQuery?
825
How can you check for a #hash in a URL using JavaScript?
750
How do you select a particular option in a SELECT element in jQuery?
1
Label fires click function twice
0
Combining 2 jquery scripts to work together
720
Wait until all jQuery Ajax requests are done?
0
Form submitting with jQuery and sending with PHP.. Can't work out why its not sending
2
jQuery UI dialog and Ajax POST in asp.net
0
Why page is shown after POST request?
0
Jquery click trigger on Success or Complete
Hot Network Questions

Is Internal`StringToDouble broken in 12.3?
trying to find the title of this time travel book
Verifying that no malicious certificate has been issued while a DNS record was pointing to an uncontrolled IP
List of problems for graduate topics?
Who to contact about ESTA refusal for previously overstaying partner of US citizen?
What does "Non procul abest" mean?
Generate a mantis's head (symmetrical triangle)
I want to package (unlocked 2GP) a Digital Experience; what metadata do I need?
Metropolis Hastings algorithm bivariate normals
How to realise this +2 evaluation in the Ruy Lopez, Steinitz defense?
Need help fitting this matrix on a page
R or S configuration?
Assuming you already have the money, how to tell when/which day of the month to pay off credit card balance?
My coauthor's university address has a typo in our published paper. What should I do?
Are these pots suitable to cook in?
Hydrogen burning vs Hydrogen fusing
How do I brew french roast coffee, so that it doesn' taste like ash
Is the post-quantum scheme quantum-resistant without regard to QROM
What is the point of using a limit order?
"must" vs "shall" - are they the same, or is one a softened version of the other?
How do Trinitarians explain Jesus' response to the scribes and Pharisees at Luke 5:20-24?
How to setup the correct fraction in word problems?
I've accidentally hidden the menubar in GIMP. How do I get it back?
Insert and remove a marker at the start of the current line

Question feed

Stack Overflow

Questions
Jobs
Developer Jobs Directory
Salary Calculator
Help
Mobile
Disable Responsiveness

Products

Teams
Talent
Advertising
Enterprise

Company

About
Press
Work Here
Legal
Privacy Policy
Terms of Service
Contact Us
Cookie Settings
Cookie Policy

Stack Exchange
Network

Technology
Life / Arts
Culture / Recreation
Science
Other

Blog
Facebook
Twitter
LinkedIn
Instagram

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev 2021.5.20.39353

Your privacy

By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.