前端密码md5加密
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--cdn引入md5-->
<script src="https://cdn.bootcdn.net/ajax/libs/blueimp-md5/2.1.0/js/md5.min.js"></script>
</head>
<body>
<form action="https://www.baidu.com/" method="post" onsubmit="return aaa()">
<p>
<span>用户名:</span></span><input type="text" id="username"name="username">
</p>
<p>
<span>密码:</span>
<input type="password"id="input-password">
</p>
<input type="hidden"id="md5-password"name="password">
<button type="submit">提交</button>
</form>
<script>
function aaa() {
alert(1);
var uname = document.getElementById('username');
var pwd = document.getElementById('input-password');
var md5_pwd = document.getElementById('md5-password');
md5_pwd.value = md5(pwd.value);
return true;
}
</script>
</body>
</html>
jQuery
jQuery API中文文档
选择器$(selector).action()
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="jquery-3.6.0.js"></script>
</head>
<body>
<a href="" id="test-jquery">点我</a>
<script>
$('#test-jquery').click(function (){
alert('hello,jQuery');
})
</script>
</body>
</html>