You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: curriculum/challenges/english/25-front-end-development/lab-favorite-icon-toggler/66bf6bacf178eac7b96d4f5e.md
+43-35Lines changed: 43 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,16 +10,18 @@ demoType: onClick
10
10
11
11
In this lab you will use JavaScript click events to toggle the appearance of a favorite icon. When the heart icon is clicked, the appearance of the heart changes from empty to filled, and vice versa.
12
12
13
-
Fulfill the user stories below and get all the tests to pass to complete the lab.**Do not copy this demo project**.
13
+
Fulfill the user stories below and get all the tests to pass to complete the lab.
14
14
15
15
**User Stories:**
16
16
17
17
1. You should have an unordered list with three items.
18
18
2. The unordered list should have the class `item-list`.
19
-
3. The three list items should contain the item name followed by a `span` element with the class `favorite-icon`.
20
-
4. The `span` element should contain the code `♡` initially to represent an empty heart.
21
-
5. When a span element containing a heart is clicked, you should add the `filled` class to the clicked `span` if it's not already present, and remove it, if it is.
22
-
6. When a `span` element containing a heart is clicked, the heart symbol should toggle between `♡` (empty heart) and `❤` (filled heart), depending on its current state.
19
+
3. The three list items should contain the item name followed by a `button` element with the class `favorite-icon`.
20
+
4. The `button` element should contain the code `♡` initially to represent an empty heart.
21
+
5. When a `button` element containing a heart is clicked, you should add the `filled` class to the clicked `button` if it's not already present, and remove it, if it is.
22
+
6. When a `button` element containing a heart is clicked, the heart symbol should toggle between `♡` (empty heart) and `❤` (filled heart), depending on its current state.
23
+
24
+
**Note:** Be sure to link your JavaScript file in your HTML. (Ex. `<script src="script.js"></script>`)
When the `span` element is clicked, and it contains the class `filled`, you should remove the class `filled` from the `span` element and change the innerHTML of the `span` element to `♡`.
70
+
When the `button` element is clicked, and it contains the class `filled`, you should remove the class `filled` from the `button` element and change the innerHTML of the `button` element to `♡`.
When the `span` element is clicked, and it doesn't contain the class `filled`, you should add the class `filled` to the `span` element and change the `innerHTML` of the `span` element to `❤`.
86
+
When the `button` element is clicked, and it doesn't contain the class `filled`, you should add the class `filled` to the `button` element and change the `innerHTML` of the `button` element to `❤`.
0 commit comments