JavaScript sweetAlert popup closes itself after a quick second

user3746183

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>
mohamedrias

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to increment a variable after 1 second in javascript

From Dev

Refresh page after "OK" alert popup with javascript

From Dev

Firebase popup window closes after calling login

From Dev

Add a button that closes the popup with popup.js

From Dev

Using SweetAlert in Javascript

From Dev

Stripe appears to create popup window but closes it on mobile

From Dev

Show popup on hover only if i hover on li after 1 second

From Dev

SQlite connection closes itself before execution

From Dev

How to save javascript varibles after a user refreshs or closes site

From Dev

Widget opens for a second then automatically closes?

From Dev

Wifi in Windows 8 kills itself after a second

From Dev

Button click makes a div popup and after 5 seconds it closes itselfs

From Dev

Popup window that auto closes in Javascript

From Dev

Javascript executes just after second click

From Dev

Refresh page after "OK" alert popup with javascript

From Dev

App closes after posting 'č','š' and 'ž'

From Dev

Firebase popup window closes after calling login

From Dev

open popup after 10 second of staying in the webpage

From Dev

Open popup before View is loaded and only load the view after the popup closes

From Dev

Javascript RegExp get second and last string after /

From Dev

Show popup on hover only if i hover on li after 1 second

From Dev

Using SweetAlert2 as popup on page load

From Dev

JavaScript SweetAlert

From Dev

Linked list: Insert function points to itself after second insertion

From Dev

JUnit stops executing after click closes the popup window

From Dev

C# console app closes itself after I run it

From Dev

Python program does not show the print() and closes itself

From Dev

Javascript: add integer after second character of string

From Dev

Html/CSS/Javascript: Popup onclick not working for second div

Related Related

  1. 1

    How to increment a variable after 1 second in javascript

  2. 2

    Refresh page after "OK" alert popup with javascript

  3. 3

    Firebase popup window closes after calling login

  4. 4

    Add a button that closes the popup with popup.js

  5. 5

    Using SweetAlert in Javascript

  6. 6

    Stripe appears to create popup window but closes it on mobile

  7. 7

    Show popup on hover only if i hover on li after 1 second

  8. 8

    SQlite connection closes itself before execution

  9. 9

    How to save javascript varibles after a user refreshs or closes site

  10. 10

    Widget opens for a second then automatically closes?

  11. 11

    Wifi in Windows 8 kills itself after a second

  12. 12

    Button click makes a div popup and after 5 seconds it closes itselfs

  13. 13

    Popup window that auto closes in Javascript

  14. 14

    Javascript executes just after second click

  15. 15

    Refresh page after "OK" alert popup with javascript

  16. 16

    App closes after posting 'č','š' and 'ž'

  17. 17

    Firebase popup window closes after calling login

  18. 18

    open popup after 10 second of staying in the webpage

  19. 19

    Open popup before View is loaded and only load the view after the popup closes

  20. 20

    Javascript RegExp get second and last string after /

  21. 21

    Show popup on hover only if i hover on li after 1 second

  22. 22

    Using SweetAlert2 as popup on page load

  23. 23

    JavaScript SweetAlert

  24. 24

    Linked list: Insert function points to itself after second insertion

  25. 25

    JUnit stops executing after click closes the popup window

  26. 26

    C# console app closes itself after I run it

  27. 27

    Python program does not show the print() and closes itself

  28. 28

    Javascript: add integer after second character of string

  29. 29

    Html/CSS/Javascript: Popup onclick not working for second div

HotTag

Archive