Title: Adding javascript to comment_reply_link to change CSS
Last modified: August 20, 2016

---

# Adding javascript to comment_reply_link to change CSS

 *  [tropicaltidbits](https://wordpress.org/support/users/tropicaltidbits/)
 * (@tropicaltidbits)
 * [14 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-to-comment_reply_link-to-change-css/)
 * Hello,
 * I am attempting to add a piece of javascript to comment reply links that will
   move one of my custom widget sidebars out of the way of the reply comment form
   by changing the sidebar’s css position style. I found where comment_reply_link
   is invoked in the comments-template.php file:
 *     ```
       if ( get_option('comment_registration') && !$user_ID )
                       $link = '<a rel="nofollow" class="comment-reply-login" href="' . esc_url( wp_login_url( get_permalink() ) ) . '">' . $login_text . '</a>';
               else
                       $link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $respond_id . "' onclick=' return addComment.moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text</a>";
               return apply_filters('comment_reply_link', $before . $link . $after, $args, $comment, $post);
       }
       ```
   
 * The js function addComment.moveForm is added to the links via the onclick event,
   and I want to include this js statement along with it:
 * `document.getElementById('widgets2').style.left='217px';`
 * This is meant to move the widgets2 div off to the right and out of the way, since
   it is already relatively-positioned. However, I can’t figure out the proper syntax
   for implementing it. I have already tried this:
 * `$link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom',
   $comment->comment_ID ) ) . "#" . $respond_id . "' onclick=' return addComment.
   moveForm(\"$add_below-$comment->comment_ID\", \"$comment->comment_ID\", \"$respond_id\",\"
   $post->ID\"); document.getElementById('widgets2').style.left=\'217px\';'>$reply_text
   </a>";`
 * and this:
 * `$link = "<a class='comment-reply-link' href='" . esc_url( add_query_arg( 'replytocom',
   $comment->comment_ID ) ) . "#" . $respond_id . "' onclick='document.getElementById('
   widgets2').style.left=\'217px\'; return addComment.moveForm(\"$add_below-$comment-
   >comment_ID\", \"$comment->comment_ID\", \"$respond_id\", \"$post->ID\")'>$reply_text
   </a>";`
 * Nothing seems to work. Any help would be appreciated.

The topic ‘Adding javascript to comment_reply_link to change CSS’ is closed to new
replies.

## Tags

 * [add](https://wordpress.org/support/topic-tag/add/)
 * [comment_reply_link](https://wordpress.org/support/topic-tag/comment_reply_link/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [tropicaltidbits](https://wordpress.org/support/users/tropicaltidbits/)
 * Last activity: [14 years, 4 months ago](https://wordpress.org/support/topic/adding-javascript-to-comment_reply_link-to-change-css/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
