Is there any way I can click on “OK” in the js confirm dialog box programatically?

I have written this jQuery function to achieve some automation in a website. Now, when “.btn-danger” is clicked a confirm dialog box opens up with two options “OK” and “Cancel”. I want to click on “OK” programmatically (maybe using js) as this will be a repetitive process.

$(".toolbar li:nth-child(2)").click(function(event) {
    setTimeout(function () {
     $("a.btn-danger").trigger("click");
    }, 1000);   
});