Category: JavaScript

How do I detect a click outside an element?

You can listen for a click event on document and then make sure #dropdownmenu is not an ancestor or the target of the clicked element by using .closest(). For those who don’t...

Native image lazy-loading for the web!

In this post, we’ll look at the new loading attribute which brings native <img> and <iframe> lazy-loading to the web!. For the curious, here’s a sneak preview of it in action:...