When user clicks on Reply button for a specific comment, how can I then hide the reply button under said comment? Do I have any access to the javascript onclick function that it calls?


Ended up using jQuery to solve this. The form moves around using javascript anyways so it doesn't break anything for users with js turned off.

//when reply button is clicked hide it
$(".comment-reply-link").click( function() {

    //when cancel button is clicked reshow reply button
$("#cancel-comment-reply-link").click( function() {

You can "wrap" the function by renaming it and defining your own function with the same name, that calls the renamed function. The "cancel" handler is internal, so you can't access that.

var oldAddComment = addComment;
addComment = {
    moveForm: function(commId, parentId, respondId, postId) {
        var retVal = oldAddComment.moveForm(commId, parentId, respondId, postId);
        // Your code to hide the link here
        return retVal;

You could also unregister the comment-reply Javascript, and register your own version. Or you can hook up extra handlers to the click event, with plain Javascript or with jQuery, as you have done.

  • Very clever. Thank-you for showing me this. How would I have figured this out on my own? – mrtsherman Mar 23 '11 at 22:07
  • I'm going to end up marking my own solution as correct because I think it is easier to implement. +1 to you though for what seems like a very appropriate solution(s). – mrtsherman Mar 24 '11 at 19:08
  • @mrtsherman: No problem, you should accept the answer that helped you solve the problem - even if you found the answer yourself! And your solution is more complete, because you also handle the cancel event. – Jan Fabry Mar 24 '11 at 19:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.