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

dom-classlist

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-classlist

Cross-browser element (including SVG) class list manipulation

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.3K
increased by17.16%
Maintainers
1
Weekly downloads
 
Created
Source

dom-classlist

Build Status

Cross-browser element class manipulation (including support for SVG elements), utilizing the native classList when possible.

Installation

npm install dom-classlist

Example

var classList = require('dom-classlist');

classList(el).toArray();
// => [ 'foo', 'bar' ]

classList(el).add('baz');
classList(el).remove('bar');
classList(el).remove(/^foo/);

classList(el).toggle('bar');
// => true
classList(el).toggle('bar');
// => false

classList(el).contains('bar');
// => false

API

.toArray()

Return an array of the element's classes.

.add(class)

Add the class to the class list.

.remove(class|regex)

Remove the class from the class list, or remove all class names matching the regex regular expression.

.toggle(class)

Toggle the class in the class list.

.contains(class)

Check if the class is present in the class list.

Browser support

  • Google Chrome
  • Firefox 4+
  • Internet Explorer 8+
  • Safari 5+
  • Opera

Keywords

FAQs

Package last updated on 24 Aug 2014

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