简体   繁体   中英

JavaScript click doesn't work the second time

I have a jQuery script to delete a message. The first time I click the link everything works fine. I click the delete link and a confirm dialog appears. Upon confirmation it redirects to another page and then back. However, the second time I click the link nothing happens.

$(document).ready(function(){
    $("a.del").click(function(){
        var conf = confirm("Confirmation message"); 
        if(conf == true)
            return true;
        else
            return false;
    });
});

Click function must work every click event.

I did it by not writing into $(document).ready(function(){});

Like:

$("a.del").click(function(){
    var conf = confirm("Confirmation message"); 
    if(conf == true)
        return true;
    else
        return false;
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM