fix: 回复用 span+JS事件绑定(取代a标签href冲突)

This commit is contained in:
2026-05-17 13:25:04 +08:00
parent 19f75da803
commit abe4c6e467
2 changed files with 16 additions and 3 deletions
+13 -1
View File
@@ -27,7 +27,7 @@ if (post_password_required()) return;
</div>
<div class="comment-item__text"><?php echo esc_html($c->comment_content); ?></div>
<div class="comment-item__reply">
<a href="#respond" onclick="document.getElementById('comment_parent').value='<?php echo $c->comment_ID; ?>';document.getElementById('comment').focus()">回复</a>
<span class="reply-link" data-comment-id="<?php echo $c->comment_ID; ?>" tabindex="0">回复</span>
</div>
</li>
<?php endforeach; ?>
@@ -79,4 +79,16 @@ if (post_password_required()) return;
</script>
<?php endif; ?>
<script>
document.querySelectorAll('.reply-link').forEach(function(el) {
el.addEventListener('click', function() {
var cid = this.getAttribute('data-comment-id');
document.getElementById('comment_parent').value = cid;
var textarea = document.getElementById('comment');
if (textarea) textarea.focus();
});
el.style.cursor = 'pointer';
});
</script>
</div>