Skip to content

Cross-browser implementation and extension of element.classList

Notifications You must be signed in to change notification settings

thomaslein/dom.classlist

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cross-browser implementation and extension of element.classList

Usage

var classList = require('dom.classlist');
var element = document.getElementById('myElement');
element.className = 'my-class some-class another-class';
classList.hasClass(element, 'my-class'); // => true
classList.addClass(element, 'yet-another-class'); // 'my-class some-class another-class yet-another-class'
classList.matchClass(element, 'yet-another'); // => 'yet-another-class'
classList.removeClass(element, 'yet-another-class'); // 'my-class some-class another-class'
classList.toggleClass(element, 'my-class'); // 'some-class another-class'
classList.replaceClass(element, 'some-class', 'some-other-class'); 'some-other-class another-class'
classlist.addTemporaryClass(element, 'anim-class', 2000);

About

Cross-browser implementation and extension of element.classList

Resources

Stars

Watchers

Forks

Packages

No packages published