Skip to content

Instantly share code, notes, and snippets.

View stasgavrylov's full-sized avatar

Stas Gavrylov stasgavrylov

View GitHub Profile
Element.prototype.closest = function(selector)
{
var element = this;
do if (element.matches(selector)) return element;
while (element = element.parentElement);
return null;
};