简易评论留言
简易评论留言

<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><title>Document</title>
</head>
<style>textarea{transition: all 2s ease;}textarea:focus{width: 300px;}span{opacity: 1;display: none;}span:focus{/*opacity:;*/}
</style><body><textarea rows="" cols=""></textarea><span>0/200</span><button type="">发布</button><ul></ul>
</body>
<script>var textarea = document.querySelector('textarea');var button = document.querySelector('button');var ul = document.querySelector('ul');var ul = document.querySelector('ul');button.onclick = function () {if (textarea.value !== '') {var li = document.createElement('li');li.innerHTML = textarea.value + "删除";ul.appendChild(li);var as = document.querySelectorAll('a');for (var i = 0; i < as.length; i++) {as[i].onclick = function () {ul.removeChild(this.parentNode);};}} else {alert("不能为空");}}textarea.addEventListener('focus', function (e) {span.style.display = 1;});textarea.addEventListener('blur', function (e) {span.style.display = 0;});
</script></html>
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
