I have the following
$("element").click(function() {
var foo=bar;
if ( foo == "bar" ) {
confirm('Dialogue');
}
});
But I would like to bool the confirm function. I’ve already tried
$("element").click(function() {
var foo=bar;
if ( foo == "bar" ) {
var confirm=confirm('Dialogue');
if (confirm==true) {
alert('true');
} else {
alert('false');
}
}
});
But no confirmation box is generated. How can I accomplish this?
You have a few issues. First issue is you are defining a variable with the name
confirm. Not good! Rename it toisGoodor something else.The other bug is right here:
confirm=trueis assignment, not a comparison.It needs to be
or just
So your code would be something like