mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-25 09:55:15 +00:00
11 lines
520 B
JavaScript
11 lines
520 B
JavaScript
|
import hasClass from './hasClass';
|
||
|
/**
|
||
|
* Adds a CSS class to a given element.
|
||
|
*
|
||
|
* @param element the element
|
||
|
* @param className the CSS class name
|
||
|
*/
|
||
|
|
||
|
export default function addClass(element, className) {
|
||
|
if (element.classList) element.classList.add(className);else if (!hasClass(element, className)) if (typeof element.className === 'string') element.className = element.className + " " + className;else element.setAttribute('class', (element.className && element.className.baseVal || '') + " " + className);
|
||
|
}
|