I have a SweetAlert popup, but it is closing itself automatically. Normally it should stay until user clicks 'OK'. (I have included and tested all SweetAlert files.)
<button class="btn btn-success" type="submit" name="submit" onclick="myFunction()">Submit</button>
<script>
function myFunction() {
swal("Submitted!", "Your Issue has been submitted!", "success");
}
</script>
Looks like it's a form submit, So when you click the button the page refreshes.That's why you see the alert for a second and it hides.
<button class="btn btn-success" type="submit" name="submit" onclick="myFunction()">Submit</button>
You must change the button type to be button
.
<button class="btn btn-success" type="button" onclick="myFunction()">Submit</button>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments