Loop Mouseover Issues

Hi, I'm making a time selector for an app and I'm having 2 issues. The 1st is the last div in the loop I have to mouse over twice for it to register, and the 2nd issue is the first 2 divs (mins 0-1) of the minute clock only mouse over when at the very edge of the clock. Note you switch clocks by clicking on the numbers in the header. Here is a code pen: https://codepen.io/General-Evie/pen/abKddYV
6 Replies
Jochem
Jochem2y ago
your first issue is that you're setting selected before you add the selected class to the new target. I'm not really awake enough to reason about why it did work properly for the other ones... moving line 29 to line 32 fixes the issue the other issue might be because the event is firing dozens of times. You've got the mouseover event on the div that's the size of the entire clock, so every event fires in I think it'd be stacking order, so top down? You should try to change it so that the event trigger is on the smaller minute indicator, not on the large clock-sized block
Ævie
ÆvieOP2y ago
this did work thank you ❤️ I thought I had to declare const before using it? I did this for the 2nd issue with no luck
document.querySelectorAll('.min b').forEach(elem => elem.addEventListener('mouseover', (event) =>
{...
document.querySelectorAll('.min b').forEach(elem => elem.addEventListener('mouseover', (event) =>
{...
Jochem
Jochem2y ago
you do, but you don't use the const for anything until if (selected != null), the rest is just strings with the value "selected" or ".selected"
Ævie
ÆvieOP2y ago
hey this doesn't really pertain to this thread, but since you've helped me a lot, I wanted to ask I'm really trying to get a good portfolio done(which this is like the first project I really have), so I can get a jr job in this field, and Idk if this project is enough or too much? Do you know what kind of things companies look for? Maybe have some advice for me getting hired as mostly self taught?
Jochem
Jochem2y ago
I'm not the best person to ask I'm afraid... My last job interview as in 2005, I've rolled from one job to the next based purely on the fact that either my boss wanted me to come with him, or I was indispensable to an important project. I got my first job based on my cover letter, and didn't even have a portfolio (though that's also not as much a thing for backend developers, which is what I was hired as) I do think this is a pretty good portfolio project though, as long as you add a more classic CRUD type project to it later. Building interesting user interfaces is not something that you see a lot I think, and it'll help you stand out
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server