键盘打出特定字母或数字弹窗彩蛋(网络转载)
4个月前 1、新建一个xiunowiki.js文件放到网站根目录 ```javascript (function() { docum...
进行更新微博客程序的时候,准备重新修改一下评论插件的回复表单定位问题,经过AI反复修改生成最终代码如下。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Comment List with Reply Form</title>
<style>
#comment-section {
margin-bottom: 20px;
}
.comment {
margin-bottom: 15px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
.reply-form {
margin-top: 10px;
}
.reply-form textarea {
width: 100%;
height: 60px;
margin-bottom: 10px;
}
#bottom-reply-form {
margin-top: 20px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
#bottom-reply-form textarea {
width: 100%;
height: 60px;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div id="comment-section">
<div class="comment">
<p>This is a comment.</p>
<button class="reply-btn">回复</button>
</div>
<div class="comment">
<p>This is another comment.</p>
<button class="reply-btn">回复</button>
</div>
</div>
<form id="bottom-reply-form">
<textarea placeholder="Write your reply..."></textarea>
<button type="submit">Submit</button>
</form>
<script>
document.addEventListener('DOMContentLoaded', function() {
const replyButtons = document.querySelectorAll('.reply-btn');
const replyForm = document.getElementById('bottom-reply-form');
let originalParent = replyForm.parentElement; // Store the original parent of the reply form
replyButtons.forEach(button => {
button.addEventListener('click', function() {
if (this.textContent === '取消') {
// If the button text is "Cancel", move the form back to the bottom
originalParent.appendChild(replyForm);
this.textContent = '回复';
} else {
// Otherwise, move the form to the clicked comment
replyButtons.forEach(btn => {
if (btn !== this) {
// Reset other buttons to "Reply"
btn.textContent = '回复';
if (btn.parentElement.classList.contains('comment') && btn.nextElementSibling === replyForm) {
originalParent.appendChild(replyForm);
}
}
});
// Move the form to the clicked comment
if (replyForm.parentElement.classList.contains('comment')) {
// If the form is already in a comment, move it back to the bottom
originalParent.appendChild(replyForm);
}
this.parentNode.appendChild(replyForm);
this.textContent = '取消';
}
});
});
});
</script>
</body>
</html>#免责声明#
本文为转载 或 原创内容,未经授权禁止转载、摘编、复制及镜像使用、转载请注明作者、出处及原文链接、违者将依法追究责任。

4个月前 1、新建一个xiunowiki.js文件放到网站根目录 ```javascript (function() { docum...

8个月前 > 以前没有用过rss这个功能,没有发现这个问题,既然发现了就要解决,以...

6个月前 这款js弹窗气泡代码非常简约,能够胜任日常弹窗业务。 
8个月前 一个代码是扒自虎绿林中的艾特功能,其实简单的修改就可以实现其它快捷...

8个月前 > 有的时候想要文章中链接地址点击后跳转到一个中转页面,可以通过下面...

7个月前 # PHP 全局变量与超全局变量性能深度分析,下面用AI解析得到的最终结果意...