Search.../

openNearestCommentBox( )

Opens the comment box closest to the element that called the function.

Description

The openNearestCommentBox() function opens the comment box that is closest to the element that called the function.

A comment box is the the input area where visitors can write a comment.

There can be up to two comment boxes on the WixComments element. They are displayed at the top and bottom of the element.

Syntax

function openNearestCommentBox([commentBoxOptions: CommentBoxOptions]): Promise<void>

openNearestCommentBox Parameters

NAME
TYPE
DESCRIPTION
commentBoxOptions
Optional
CommentBoxOptions

Effect options for opening the comment box.

Returns

Return Type:

Promise<void>

Related Content:

Was this helpful?

Open a comment box with no options

Copy Code
1$w("#myCommentsWidget").openNearestCommentBox();
Open a comment box with options

Copy Code
1const commentBoxOptions = {
2 focus: true,
3 scroll: false
4};
5
6$w("#myCommentsWidget").openNearestCommentBox(commentBoxOptions);
Open a comment box with an button click event

Copy Code
1$w("#myButton").onClick( () => {
2 $w("#myCommentsWidget").openNearestCommentBox();
3});