fix: 回复用 span+JS事件绑定(取代a标签href冲突)
This commit is contained in:
+13
-1
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user