Article Preview Component

Please log in to post a comment
Log in with GitHubCommunity feedback
- P@giropa832
Great work, the animation looks slick!
Here is some feedback on the JS.
Instead of assigning each button via the button selector, you can select all buttons like this
const buttons = document.querySelectorAll('button');
To show and hide the share box, you can just simply use a toggle, assigning the same
eventListener
to each button with aforEach
loop, like this:shareButton.forEach(button => button.addEventListener('click', () => { sharediv.classList.toggle('yourClasstoShowandHide'); }) );
Since in this case you only had two buttons to work with, it may not make sense, however it is a great opportunity to practice some Javascript looping.
Keep up the good work!
Join 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