Design comparison
Solution retrospective
Tried to use DOM for the first time. Everything in vanilla. It gave me a challenge on how do i tackle attaching javascript to the page.
What challenges did you encounter, and how did you overcome them?DOMs, overcomed through researching and studying.
What specific areas of your project would you like help with?DOM, transitions, animations
Community feedback
- @kodan96Posted 7 months ago
hi there! ๐๐
If you mean interacting with the DOM using JavaScript we have a couple of options to select and modify DOM elements:
querySelector()
querySelectorAll()
- getElementbyId / ClassName / Tagname
innerHTML()
text()
you can look up use cases for each of (speaking of which, there's actually
forEach()
for looping through an array of elements selected by any of the methods mentioned before โ๏ธโ๏ธ ) theseFrom there you can listen for events with the amply named
.addEventListener
method, and you can modify elements based on the interaction. You can add previously defined CSS classes modifying the elementscolor, display
etc. properties, or you can use the{selector}.style.{property}
JS syntax to modify them directly (this approach is more hardware-heavy for clients)transitions used to define the same behaviours that
eventListeners
are listening to, but in CSS. you need to define what properties you want to apply the transition to. For example:.card { left: 0; transition: left .5s ease-in 1s; // property: duration easing-method delay; } .card:hover { left: 2vw; }
would apply a transition to
.card
'sleft
property when card is hovered overanimations are the same idea, but you need to define
@keyframe
at-rules for themHope this was helpful! ๐
Good luck and happy coding! ๐ช
Marked as helpful0
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