让 WordPress 回复评论自动加上@符号(代码版)

转自点点 13 年前 回复

, , , ,

通用版是这个Zww的:

/* @reply js by zwwooooo */
jQuery(document).ready(function($){ //Begin jQuery
    $('.reply').click(function() {
    var atid = '"#' + $(this).parent().attr("id") + '"';
    var atname = $(this).prevAll().find('cite:first').text();
    $("#comment").attr("value","@" + atname + " ").focus();
});
    $('.cancel-comment-reply a').click(function() { //点击取消回复评论清空评论框的内容
    $("#comment").attr("value",'');
});
})  //End jQuery

至于Jquery的用法就不多讲了。可以放在JS里,也可以放在 Header.php 里,前提是必须调用 Jquery 库。在 Header.php 里边加这样一句话。
然后把上边代码保存成 reply.js 文件。上传到根目录中,再 header.php 里边再加上一条。
另外可能我的模板和别人的不太一样。大家可以参考一下这里。

/* @reply js by zwwooooo */
jQuery(document).ready(function($){ //Begin jQuery
    $('.reply').click(function() {
        var atid = '"#' + $(this).parent().parent().attr("id") + '"';
        var atname = $(this).parent().parent().find("cite:first").text();
        $("#comment").attr("value", "@" + atname + " ").focus()
    });
    $('#cancel-comment-reply-link').click(function() {
        $("#comment").attr("value", '')
    });
})  //End jQuery

转自http://www.forece.net/post/2653.htm

支付宝打赏微信打赏

如果此文对你有帮助,欢迎打赏作者。

发表评论

欢迎回来 (打开)

(必填)