Design comparison
Solution retrospective
Uhm... i took up to 3 hrs doing this project. its the first time i am doing something like this using JavaScript. I am happy i didn't let fear stop me
What challenges did you encounter, and how did you overcome them?I have this challenge with toggling between the two signs, minus and plus. I didnt even implement it. I need help on how to do it. Two, most of my code was a code along, i would like to really understand it.
What specific areas of your project would you like help with?I need someone to help me understand this code that i have written
Community feedback
- @MikDra1Posted 3 months ago
Ok,
So if I were you I'd have one image element that will change it's src attribute value in the JS
If you find this comment useful please mark it as helpful π
Here is how:
HTML:
<img class="img" src="./assets/images/icon-plus.svg"
JS:
const img = document.querySelector('.img'); let isOpen = false; img.addEventListener('click', function()) { if(!isOpen) { img.src = "./assets/images/icon-minus.svg" isOpen = true; } else { img.src ="./assets/images/icon-plus.svg" isOpen = false; } }
Marked as helpful0 - @MikDra1Posted 3 months ago
Nice one @OdohRitaπ
If you want to implement the plus minus icon toggling I would suggest using the src property on the image in JavaScript as down here
image.src = 'images/minus.jpeg'
If you find this comment useful please mark it as helpful π
If you have any more questions feel free to ask them β
Good job and keep going πππ
0
Please log in to post a comment
Log in with GitHubJoin our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord