typecho实现多个文章部分内容加密教程
8个月前 > 需求说明 typecho文章虽然自带了加密功能,可是有时候不太人性化,例如...
进行更新微博客程序的时候,准备重新修改一下评论插件的回复表单定位问题,经过AI反复修改生成最终代码如下。
<!DOCTYPE html><br />
<html lang="en"><br />
<head><br />
<meta charset="UTF-8"><br />
<meta name="viewport" content="width=device-width, initial-scale=1.0"><br />
<title>Comment List with Reply Form</title><br />
<style><br />
#comment-section {<br />
margin-bottom: 20px;<br />
}<br />
<br />
.comment {<br />
margin-bottom: 15px;<br />
padding: 10px;<br />
border: 1px solid #ccc;<br />
border-radius: 5px;<br />
}<br />
<br />
.reply-form {<br />
margin-top: 10px;<br />
}<br />
<br />
.reply-form textarea {<br />
width: 100%;<br />
height: 60px;<br />
margin-bottom: 10px;<br />
}<br />
<br />
#bottom-reply-form {<br />
margin-top: 20px;<br />
padding: 10px;<br />
border: 1px solid #ccc;<br />
border-radius: 5px;<br />
}<br />
<br />
#bottom-reply-form textarea {<br />
width: 100%;<br />
height: 60px;<br />
margin-bottom: 10px;<br />
}<br />
</style><br />
</head><br />
<body><br />
<div id="comment-section"><br />
<div class="comment"><br />
<p>This is a comment.</p><br />
<button class="reply-btn">回复</button><br />
</div><br />
<div class="comment"><br />
<p>This is another comment.</p><br />
<button class="reply-btn">回复</button><br />
</div><br />
</div><br />
<form id="bottom-reply-form"><br />
<textarea placeholder="Write your reply..."></textarea><br />
<button type="submit">Submit</button><br />
</form><br />
<script><br />
document.addEventListener('DOMContentLoaded', function() {<br />
const replyButtons = document.querySelectorAll('.reply-btn');<br />
const replyForm = document.getElementById('bottom-reply-form');<br />
let originalParent = replyForm.parentElement; // Store the original parent of the reply form<br />
<br />
replyButtons.forEach(button => {<br />
button.addEventListener('click', function() {<br />
if (this.textContent === '取消') {<br />
// If the button text is "Cancel", move the form back to the bottom<br />
originalParent.appendChild(replyForm);<br />
this.textContent = '回复';<br />
} else {<br />
// Otherwise, move the form to the clicked comment<br />
replyButtons.forEach(btn => {<br />
if (btn !== this) {<br />
// Reset other buttons to "Reply"<br />
btn.textContent = '回复';<br />
if (btn.parentElement.classList.contains('comment') && btn.nextElementSibling === replyForm) {<br />
originalParent.appendChild(replyForm);<br />
}<br />
}<br />
});<br />
<br />
// Move the form to the clicked comment<br />
if (replyForm.parentElement.classList.contains('comment')) {<br />
// If the form is already in a comment, move it back to the bottom<br />
originalParent.appendChild(replyForm);<br />
}<br />
this.parentNode.appendChild(replyForm);<br />
this.textContent = '取消';<br />
}<br />
});<br />
});<br />
});<br />
</script><br />
</body><br />
</html><br />#免责声明#
本文为转载 或 原创内容,未经授权禁止转载、摘编、复制及镜像使用、转载请注明作者、出处及原文链接、违者将依法追究责任。

8个月前 > 需求说明 typecho文章虽然自带了加密功能,可是有时候不太人性化,例如...

5个月前 项目中用到的一个localStorage工具,可以用于token存储、数据缓存,支持过期...

8个月前 PHP超全局变量不同使用方法的差异有多大?,列如下面的代码案例,各位网...

8个月前 > 为什么要过滤侧边栏评论内容? 例如:你的模板中有个私密功能,有网...

8个月前 > 第一步在需要引入jquery库,这一步不能少,可以使用本地js或者下面的cdn或...

8个月前 > 首先声明,下面的代码基本都是用AI写作,博主只是辅助提供意见修改。...