Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dom-dollar

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

dom-dollar

< 1KB library for DOM selections in JavaScript

  • 1.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

dom$

< 1KB library for DOM selections in JavaScript

Download

Development Version Production Version

About

Even though it's used less and less, jQuery is still used a lot for its single function that does a lot of different DOM operations. With the increasing browsers support for simple features, some of jQuery's cross-browser compatibility methods have become outdated. This library is made to make it easy to do anything with the DOM, but still use the (much faster) vanilla DOM methods.

dom$ supports a lot of browsers, even back to IE8! It's an easy way to create, modify, and find DOM elements dynamically.

This library also works well with the Stream.js library.

Examples

Setting all headers to blue:

dom$('h1, h2, h3, h4, h5').each(function (elem) {
    elem.style.color = 'blue'; // using `this` would also work here
});

Adding 2 DOM elements, then using Stream.js to find ones with a certain class:

var text = dom$('p.text');
var elements = dom$('<p class="text">This is more text</p><p>Even more!</p>');
elements.each(document.body.appendChild.bind(document.body));

new Stream(text.getElements())
        .filter(function (elem) { return elem.innerHTML.indexOf('text') > 0 })
        .forEach(console.log.bind(console));

Functions

dom$(elements) => dom$

Creates a new dom$.

dom$.prototype.each(function(element:Element)) => dom$

Iterates through all of the elements and returns instance of self.

dom$.prototype.empty() => dom$

Removes all child nodes and returns instance of self.

dom$.prototype.remove() => dom$

Removes all nodes and returns instance of self.

dom$.prototype.getElements() => Element[]

Returns all elements as an array.

Keywords

FAQs

Package last updated on 22 Sep 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