正则表达式在代码解析中的高级应用
这是一个简单的登录页面:
<!DOCTYPE html>
<html>
<head>
<title>登录页面</title>
</head>
<body>
<div class="container">
<form id="loginForm">
<input type="text" id="username" placeholder="用户名">
<input type="password" id="password" placeholder="密码">
<button type="submit">登录</button>
</form>
</div>
</body>
</html>
.container {
max-width: 400px;
margin: 100px auto;
padding: 20px;
border: 1px solid #ddd;
border-radius: 8px;
}
input, button {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 4px;
}
document.getElementById('loginForm').addEventListener('submit', function(e) {
e.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
console.log('登录信息:', username, password);
});

浙公网安备 33010602011771号