留言板代码html(留言内容
```html
body {
fontfamily: Arial, sansserif;
margin: 0;
padding: 20px;
backgroundcolor: f4f4f4;
}
container {
maxwidth: 600px;
margin: 0 auto;
backgroundcolor: fff;
padding: 20px;
borderradius: 5px;
boxshadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
textalign: center;
color: 333;
}
form {
margintop: 20px;
}
label, input, textarea {
display: block;
marginbottom: 10px;
}
input[type="submit"] {
backgroundcolor: 007bff;
color: fff;
border: none;
padding: 10px 20px;
cursor: pointer;
borderradius: 5px;
}
input[type="submit"]:hover {
backgroundcolor: 0056b3;
}
.message {
marginbottom: 20px;
border: 1px solid ddd;
padding: 10px;
borderradius: 5px;
}
.message p {
margin: 0;
}
留言板
document.getElementById("messageForm").addEventListener("submit", function(event) {
event.preventDefault();
var name = document.getElementById("name").value;
var email = document.getElementById("email").value;
var message = document.getElementById("message").value;
var messagesDiv = document.getElementById("messages");
var messageElement = document.createElement("div");
messageElement.classList.add("message");
messageElement.innerHTML = "
姓名:" name "
""
邮箱:" email "
""
留言内容:" message "
";messagesDiv.prepend(messageElement);
document.getElementById("messageForm").reset();
});