New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

domhelpers

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

domhelpers

DOMhelpers is a (very) small collection of some handy utility functions which help you query the DOM.

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
203
increased by16%
Maintainers
1
Weekly downloads
 
Created
Source

domhelpers

DOMhelpers is a (very) small collection of some handy utility functions which help you query the DOM.

getClosest(element, selector)

Get the closest element from element which matches selector. This includes the element itself.

<div class="el1">
  <div class="el2"></div>
</div>
var el2 = document.querySelector('.el2');
console.log(getClosest(el2, '.el1')); // div.el1
console.log(getClosest(el2, '.el2')); // div.el2

getParent(element, selector)

Get the closest element from element which matches selector. This does NOT include the element itself, instead it searches from the element's parentNode.

<div class="el1">
  <div class="el2"></div>
</div>
var el2 = document.querySelector('.el2');
console.log(getClosest(el2, '.el1')); // div.el1
console.log(getClosest(el2, '.el2')); // undefined

getParents(element, selector)

Get all parents from element which match selector. This function always returns an array.

<div class="el1">
  <div class="el1">
    <div class="el2"></div>
  </div>
</div>
var el2 = document.querySelector('.el2');
console.log(getClosest(el2, '.el1')); // [div.el1, div.el1]
console.log(getClosest(el2, '.el2')); // []

FAQs

Package last updated on 26 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc