1.加载两个文件件
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script src="vendor/sweetalert/dist/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="/vendor/sweetalert/dist/sweetalert.css">
</head>
2.调用:
<script>
$('#btnLogin').click(function () {
// alert("........alery....");
// swal("hello");
sweetAlert("hello");
});
</script>
完整代码:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>登录页面</title>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script src="vendor/sweetalert/dist/sweetalert.min.js"></script>
<link rel="stylesheet" type="text/css" href="/vendor/sweetalert/dist/sweetalert.css">
</head>
<body style="text-align: center">
<form id="newForm" onsubmit="return false">
<div>
<input id="loginName", name="loginName" type="text">
</div>
<div>
<input id="loginPwd", name="loginPed" type="password">
</div>
<button type="submit" id="btnLogin">登陆</button>
</form>
<script>
$('#btnLogin').click(function () {
// alert("........alery....");
// swal("hello");
sweetAlert("hello");
});
</script>
<!--<th:block th:replace="js/login_js"></th:block>-->
</body>
</html>