1e41f4b71Sopenharmony_ci# Adding Interactions
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciYou can make the UI interactive by binding events to components. This section describes how to bind **\<div>**, **\<text>**, and **\<image>** components to click events to build a thumb up button, as shown in the following figure.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci**Figure 1** Thumb up button effect
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ci![en-us_image_0000001267647901](figures/en-us_image_0000001267647901.gif)
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ciThe thumb up button is implemented by binding a click event to a &lt;div&gt; component. The \<div> component contains an **\<image>** component and a \<text> component.
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci- The **\<image>** component is used to display unselected and selected (highlighted) thumbs up images. The click event function alternately updates the paths of the images that are liked and not liked.
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci- The **\<text>** component is used to display the number of thumbs up. The number is updated in the function of the click event.
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci
18e41f4b71Sopenharmony_ciThe click event calls the **likeClick()** function defined in the .js file. You can change the value of **isPressed** to update the image component. If the value of **isPressed** is **true**, the number of thumbs up is incremented by 1. The **likeClick()** function takes effect on the **\<div>** component in the .hml file. The style of each child component for the thumbs up button is set in the .css file. The following is an example:
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci```html
22e41f4b71Sopenharmony_ci<!-- xxx.hml -->
23e41f4b71Sopenharmony_ci<!-- Thumb up button -->
24e41f4b71Sopenharmony_ci<div>
25e41f4b71Sopenharmony_ci  <div class="like" onclick="likeClick">
26e41f4b71Sopenharmony_ci    <image class="like-img" src="{{likeImage}}" focusable="true"></image>
27e41f4b71Sopenharmony_ci    <text class="like-num" focusable="true">{{total}}</text>
28e41f4b71Sopenharmony_ci  </div>
29e41f4b71Sopenharmony_ci</div>
30e41f4b71Sopenharmony_ci```
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci```css
34e41f4b71Sopenharmony_ci/* xxx.css */
35e41f4b71Sopenharmony_ci.like {
36e41f4b71Sopenharmony_ci  width: 104px;
37e41f4b71Sopenharmony_ci  height: 54px;
38e41f4b71Sopenharmony_ci  border: 2px solid #bcbcbc;
39e41f4b71Sopenharmony_ci  justify-content: space-between;
40e41f4b71Sopenharmony_ci  align-items: center;
41e41f4b71Sopenharmony_ci  margin-left: 72px;
42e41f4b71Sopenharmony_ci  border-radius: 8px;
43e41f4b71Sopenharmony_ci}
44e41f4b71Sopenharmony_ci.like-img {
45e41f4b71Sopenharmony_ci  width: 33px;
46e41f4b71Sopenharmony_ci  height: 33px;
47e41f4b71Sopenharmony_ci  margin-left: 14px;
48e41f4b71Sopenharmony_ci}
49e41f4b71Sopenharmony_ci.like-num {
50e41f4b71Sopenharmony_ci  color: #bcbcbc;
51e41f4b71Sopenharmony_ci  font-size: 20px;
52e41f4b71Sopenharmony_ci  margin-right: 17px;
53e41f4b71Sopenharmony_ci}
54e41f4b71Sopenharmony_ci```
55e41f4b71Sopenharmony_ci
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ci```js
58e41f4b71Sopenharmony_ci// xxx.js
59e41f4b71Sopenharmony_ciexport default {
60e41f4b71Sopenharmony_ci  data: {
61e41f4b71Sopenharmony_ci    likeImage: '/common/unLike.png',
62e41f4b71Sopenharmony_ci    isPressed: false,
63e41f4b71Sopenharmony_ci    total: 20,
64e41f4b71Sopenharmony_ci  },
65e41f4b71Sopenharmony_ci  likeClick() {
66e41f4b71Sopenharmony_ci    var temp;
67e41f4b71Sopenharmony_ci    if (!this.isPressed) {
68e41f4b71Sopenharmony_ci      temp = this.total + 1;
69e41f4b71Sopenharmony_ci      this.likeImage = '/common/like.png';
70e41f4b71Sopenharmony_ci    } else {
71e41f4b71Sopenharmony_ci      temp = this.total - 1;
72e41f4b71Sopenharmony_ci      this.likeImage = '/common/unLike.png';
73e41f4b71Sopenharmony_ci    }
74e41f4b71Sopenharmony_ci    this.total = temp;
75e41f4b71Sopenharmony_ci    this.isPressed = !this.isPressed;
76e41f4b71Sopenharmony_ci  },
77e41f4b71Sopenharmony_ci}
78e41f4b71Sopenharmony_ci```
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ciArkUI also provides many form components, such as switches, tags, and pickers, for you to flexibly lay out pages and improve their interactions with users. For details, see **Container Components**.
82