Hello, I am doing an event called onclick of js, what happens is that when I press the button, it does not send me the "Confirm" alerts.
the code is the following.
<script>
$(document).ready(function(){
$("#DANGERDANGERDANGER").click(function() {
if (confirm("¿Cancelar atencion?")) {
if (confirm("¿Seguro?")) {
if (confirm("¿De veritas?")) {
if (confirm("Ok, confio en ti")) {
if (confirm("Ultima oportunidad para arrepentirse...")) {
...
}
}
}
}
}
});
});
</script>
And where I am calling it is with the following button
<button type="button" class="btn btn-primary" id="DANGERDANGERDANGER" onclick="DANGERDANGERDANGER();">
Boton
</button>
I call the j query and it is below, that is, in the footer. If you are wondering why the integrity is not there, it is because I have kamsperky and for security reasons I had problems.
<script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script>
Sorry for not specifying, but the error that sends me is the following
The error it shows you is because you are trying to call a function that does not exist.
The way to do it with javascript is as follows:
I'll explain why: when you create the button you are already giving it the onclick event so that it calls the function
DANGERDANGERDANGER
, and what you are doing with jquery is again taking the button and giving it another eventonclick
to execute an anonymous functionThe other way with jquery is:
Here what you do is create the button without any event, but in the
onready
Jquery function you get the button by itsid
and you set the event to execute an anonymous function, it is also valid in this way but you must select one