confirmation box on span using jquery


I want to show confimration box to user, after user clicks on a button.
I am willing to use jquery here.

here is my demo code

<span class="DeleteAction">
<i class='fa fa-remove'></i>
<span>

Asked by:- neena
1
: 4639 At:- 5/10/2017 3:45:21 PM
jquery javascript html







2 Answers
profileImage Answered by:- vikas_jk

Yes you can do it simply, using jquery code below

$(document).on('click', '.DeleteAction', function () {
           var c = confirm("Are you sure do you want to delete it");
           if (c == true) {
                //do something here
           }
            else
            {
             return false
            }

});

 

2
At:- 5/10/2017 3:49:23 PM Updated at:- 5/10/2017 3:50:19 PM


profileImage Answered by:- pika

You can have this HTML

<span id="delete-button">Delete</span>

JS

<script>
$("#delBtn").click(function(){
    if(confirm("Are you sure you want to delete this?")){
        // do something here.
    }
    else{
        return false;
    }
});
</script>

This should work, thanks

1
At:- 1/24/2022 11:01:37 AM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use