I've been trying to use SweetAlert in HTML, and for some reason, it's not recognizing swal() as a function. It's just putting it as text onto the he page. I'm extremely new to HTML, as Lua and Node.js are my primary languages.
This is what appears on the page.
swal("test", { icon: "warning", });
Code:
<html>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
swal("test", {
icon: "warning",
});
</html>
If anyone with more experience in HTML is able to point me in the right direction, it would be appreciated.
JavaScript, when inside of an HTML file, should be enclosed in <script></script>
tags. You also need to include a head
section, so your HTML will look something like this:
<html>
<head>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
</head>
<body>
<script>
swal('test', {icon: 'warning'});
</script>
</body>
</html>