Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Sylvert's avatar

SweetAlert vs SweetAlert 2

Hello guys, anyone can tell me the diff in these two? What it's better?

0 likes
6 replies
bashy's avatar

The original SweetAlert https://github.com/t4t5/sweetalert wasn't updated for a while so someone forked it and created the 2 one. The original is now back on track so you can pick either.

I think the original is OK to use.

1 like
Sylvert's avatar

How can i put html on the alert? I try the next but doesn't works

swal({
    title: 'Oops!',
    content: 'Se encontraron problemas con el sistema de registro.<br><b>Por favor, comunicate con la administración.</b>',
    icon: 'error'
});
Cronix's avatar

@sylvert Try using 'html' instead of 'content'. It probably depends on if you're using the original sweetalert, or sweetalert2. I know 'html' works with sweetalert2, not sure on the original sweetalert as I don't use it.

Sylvert's avatar

Im using sweetalert, it's use the parameters content for html, but not sure how to using it properly.

Cronix's avatar

I really don't know. The docs don't show anything about it. I'd suggest swapping it out for sweetalert2. They even show html in the examples, and it's almost the same as the original sweetalert. https://limonte.github.io/sweetalert2/

Sylvert's avatar

I solved it

/* Show the error alert */
                    let message = document.createElement('span');
                    message.innerHTML = 'Se encontraron problemas con el sistema de registro.<br><b>Por favor, comunicate con la administración.</b>';

                    swal({
                        title: 'Oops!',
                        content: message,
                        icon: 'error'
                    }).then(() => window.location.href = '/');

Please or to participate in this conversation.