# learnpress/4.3.9/assets/src/apps/js/frontend/single-curriculum/components/comment.js

LearnPress – WordPress LMS Plugin for Create and Sell Online Courses, version 4.3.9. 54 lines.

- Page: https://pluginprobe.com/plugins/learnpress/4.3.9/code/assets/src/apps/js/frontend/single-curriculum/components/comment.js
- Raw: https://pluginprobe.com/plugins/learnpress/4.3.9/raw/assets/src/apps/js/frontend/single-curriculum/components/comment.js
- Modified: 2026-06-08T02:53:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/learnpress/4.3.9/code/assets/src/apps/js/frontend/single-curriculum/components/comment.js#L10-L20`.

```javascript
/**
 * Toogle form Comment for Lesson.
 *
 * @author Nhamdv.
 */

export const commentForm = () => {
	const btn = document.querySelector( '.lp-lesson-comment-btn' );

	if ( ! btn ) {
		return;
	}

	const btnOpen = btn.textContent;
	const btnClose = btn.dataset.close;
	const hashComment = window.location.hash;

	if ( hashComment.includes( 'comment' ) ) {
		btn.parentNode.classList.add( 'open-comments' );
	}

	const toogleText = ( btn, btnParent ) => {
		if ( btnParent.classList.contains( 'open-comments' ) ) {
			btn.textContent = btnClose;
		} else {
			btn.textContent = btnOpen;
		}
	};

	toogleText( btn, btn.parentNode );

	btn.addEventListener( 'click', ( e ) => {
		e.preventDefault();

		btn.parentNode.classList.toggle( 'open-comments' );
		toogleText( btn, btn.parentNode );
	} );

	// Use for Rest API.
	// const toogle = $( '#learn-press-item-comments-toggle' );

	// toogle.on( 'change', async function() {
	// 	if ( ! toogle[ 0 ].checked ) {
	// 		return;
	// 	}

	// 	const response = await wp.apiFetch( {
	// 		path: 'lp/v1/courses/339/item-comments/50',
	// 	} );

	// 	$( '.learn-press-comments' ).html( response.comments );
	// } );
};

```
