1e41f4b71Sopenharmony_ci# Adding a Comment 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ciAfter a user enters a comment and clicks the submit button, the content is displayed in the comment area. The user can click the delete button to delete the current comment and enter another comment again. 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciTo set such a comment area on a page, you need to associate a click event with **\<div>**, **\<text>**, and **\<input>**. You can use the **\<input>** component to obtain the comment entered by a user, use the **\<text>** component to display the comment, and use commentText to mark the **\<text>** component (controlled by the if attribute). Associate the click event with the **\<text>** component that contains Done and Delete to update the **commentText** and **inputValue**. The following is an example: 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci```html 10e41f4b71Sopenharmony_ci<!-- xxx.hml --> 11e41f4b71Sopenharmony_ci<div class="container"> 12e41f4b71Sopenharmony_ci <text class="comment-title">Comment</text> 13e41f4b71Sopenharmony_ci <div if="{{!commentText}}"> 14e41f4b71Sopenharmony_ci <input class="comment" value="{{inputValue}}" onchange="updateValue()"></input> 15e41f4b71Sopenharmony_ci <text class="comment-key" onclick="update" focusable="true">Done</text> 16e41f4b71Sopenharmony_ci </div> 17e41f4b71Sopenharmony_ci <div if="{{commentText}}"> 18e41f4b71Sopenharmony_ci <text class="comment-text" focusable="true">{{inputValue}}</text> 19e41f4b71Sopenharmony_ci <text class="comment-key" onclick="update" focusable="true">Delete</text> 20e41f4b71Sopenharmony_ci </div> 21e41f4b71Sopenharmony_ci</div> 22e41f4b71Sopenharmony_ci``` 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci```css 26e41f4b71Sopenharmony_ci/* xxx.css */ 27e41f4b71Sopenharmony_ci.container { 28e41f4b71Sopenharmony_ci margin-top: 24px; 29e41f4b71Sopenharmony_ci background-color: #ffffff; 30e41f4b71Sopenharmony_ci} 31e41f4b71Sopenharmony_ci.comment-title { 32e41f4b71Sopenharmony_ci font-size: 40px; 33e41f4b71Sopenharmony_ci color: #1a1a1a; 34e41f4b71Sopenharmony_ci font-weight: bold; 35e41f4b71Sopenharmony_ci margin-top: 40px; 36e41f4b71Sopenharmony_ci margin-bottom: 10px; 37e41f4b71Sopenharmony_ci} 38e41f4b71Sopenharmony_ci.comment { 39e41f4b71Sopenharmony_ci width: 550px; 40e41f4b71Sopenharmony_ci height: 100px; 41e41f4b71Sopenharmony_ci background-color: lightgrey; 42e41f4b71Sopenharmony_ci} 43e41f4b71Sopenharmony_ci.comment-key { 44e41f4b71Sopenharmony_ci width: 150px; 45e41f4b71Sopenharmony_ci height: 100px; 46e41f4b71Sopenharmony_ci margin-left: 20px; 47e41f4b71Sopenharmony_ci font-size: 32px; 48e41f4b71Sopenharmony_ci color: #1a1a1a; 49e41f4b71Sopenharmony_ci font-weight: bold; 50e41f4b71Sopenharmony_ci} 51e41f4b71Sopenharmony_ci.comment-key:focus { 52e41f4b71Sopenharmony_ci color: #007dff; 53e41f4b71Sopenharmony_ci} 54e41f4b71Sopenharmony_ci.comment-text { 55e41f4b71Sopenharmony_ci width: 550px; 56e41f4b71Sopenharmony_ci height: 100px; 57e41f4b71Sopenharmony_ci text-align: left; 58e41f4b71Sopenharmony_ci line-height: 35px; 59e41f4b71Sopenharmony_ci font-size: 30px; 60e41f4b71Sopenharmony_ci color: #000000; 61e41f4b71Sopenharmony_ci border-bottom-color: #bcbcbc; 62e41f4b71Sopenharmony_ci border-bottom-width: 0.5px; 63e41f4b71Sopenharmony_ci} 64e41f4b71Sopenharmony_ci``` 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci 67e41f4b71Sopenharmony_ci```js 68e41f4b71Sopenharmony_ci// xxx.js 69e41f4b71Sopenharmony_ciexport default { 70e41f4b71Sopenharmony_ci data: { 71e41f4b71Sopenharmony_ci inputValue: '', 72e41f4b71Sopenharmony_ci commentText: false, 73e41f4b71Sopenharmony_ci }, 74e41f4b71Sopenharmony_ci update() { 75e41f4b71Sopenharmony_ci this.commentText = !this.commentText; 76e41f4b71Sopenharmony_ci }, 77e41f4b71Sopenharmony_ci updateValue(e) { 78e41f4b71Sopenharmony_ci this.inputValue = e.text; 79e41f4b71Sopenharmony_ci }, 80e41f4b71Sopenharmony_ci} 81e41f4b71Sopenharmony_ci``` 82