<style>
{
margin: 0;
padding: 0;
box-sizing: border-box;
}
li {
list-style: none;
}
body {
background-color:rgb(174, 236, 236);
color: #555;
}
.comment {
width: 85%;
margin: 1em auto;
display: grid;
gap: 0.5em;
}
.comment #content {
resize: none;
border:none;
padding: 0.5em;
outline: none;
}
.comment #content:focus,
.comment #content:hover {
box-shadow: 0 0 8px steelblue;
transition: 0.6s;
}
.comment .submit {
width: 30%;
margin-left: auto;
background-color: lightseagreen;
border: none;
outline: none;
color: white;
height: 2.5em;
}
.comment .submit:hover {
background-color: seagreen;
transition: 0.6s;
cursor: pointer;
}
.list {
width: 80%;
/ background-color: yellow; /
margin: auto;
padding: 1em;
}
.del-btn {
background-color: wheat;
color: red;
padding:0.5em 1em;
/ height: 2.2em; */
border:none;
outline: none;
}
.del-btn:hover {
cursor: pointer;
background-color: lime;
}
</style>
const comment = document.querySelector('.comment');const content = comment.content;const submitBtn = comment.submit;const commentList = document.querySelector('.list');
submitBtn.onclick = (ev) => {
let value = content.value.trim();if (value.length > 0 && value.length <= 100) {const newComment = document.createElement("li");newComment.textContent = value;newComment.style.borderBottom = "1px solid white";newComment.style.minHeight = "3em";
commentList.prepend(newComment);
alert("left message successful");
content.focus();} else {alert("no content or too many words");content.focus();return false;}};
this.parentNode.remove();alert("delete successful");content.focus();return false;}};
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号