The idea is to have 30 days (in a row) of blog posts. The authors may vary. Subjects might not be serious; they don’t need to be. The goal is to get out of our comfort zone and put something out there in hopes of helping / inspiring someone else. Most important, to have fun.
Now that the boring stuff is out of the way, here’s a tiny “ahhhhhh” tip I can share. It’s super basic, but I hear people ask this question all the time.
If you would like a more elegant explanation, check out the ever useful, Stack Overflow.
Since we’re on the topic of
return values… let’s go over another small trick. Again, it’s nothing mind blowing or revolutionary. I’m sure you’ve seen this pattern before (assume hondaElement is a class on an “a” tag:
1 2 3 4
preventDefault… well, read that out loud and I bet you can guess what it’s doing.
And here’s another common pattern that is used:
1 2 3 4
So, both examples stop the default action of the
a firing when clicked. The second example takes things a bit further. It not only stops the default action from firing, it also stops event bubbling. It’s the same as doing:
1 2 3 4 5
Now, the caveat… I believe this only applies to jQuery. Vanilla js still needs to have both
e.stopPropagation(). If anyone has some extra info on that, please, leave a comment and set the record straight.