Reacting to events with JavaScript is the foundation of a dynamic web experience. If it is one click
event or other typical action, it is important to respond to this action. We started by assigning events to specific elements and then moved to event delegation for efficiency, but did you know that you can identify elements by position on the page? Let’s have a look document.elementFromPoint
and document.elementsFromPoint
.
That document.elementFromPoint
method accepts x
and y
parameters to identify the top element of a point:
const element = document.elementFromPoint(100, 100); //
If you want to know the whole element stack, you can use document.elementsFromPoint
:
const elements = document.elementsFromPoint(100, 100); // [, , ]
That elementFromPoint
and elementsFromPoint
are really useful for experiences where developers don’t want to assign individual events. Gaming and entertainment sites could benefit from these features. How would you use them?
Tips for getting started with Bitcoin and cryptocurrencies
One of the most rewarding experiences of my life, both financially and logically, has been buying and managing cryptocurrencies such as Bitcoin, Litecoin, Ethereum. Like learning any new technology, I made rookie mistakes along the way, but learned some best practices along the way. Check out…
Flashy FAQs using MooTools sliders
I often qualify a great website as one that pays attention to detail and makes all the “little things” seem like a lot of time was spent on them. Let’s face it – FAQs are as boring as they come. That is, until you…