Add class to the element. The second parameter can be a single class name or an array of class names.
class
Basic Usage:
import { addClass } from "mazey";const ele = document.querySelector("#box");addClass(ele, "test"); Copy
import { addClass } from "mazey";const ele = document.querySelector("#box");addClass(ele, "test");
Output:
<div id="box" class="test"></div> Copy
<div id="box" class="test"></div>
Advanced Usage:
import { addClass, genBrowserAttrs } from "mazey";const ele = document.querySelector("html");addClass(ele, genBrowserAttrs()); Copy
import { addClass, genBrowserAttrs } from "mazey";const ele = document.querySelector("html");addClass(ele, genBrowserAttrs());
<html class="windows desktop webkit chrome"></html> Copy
<html class="windows desktop webkit chrome"></html>
Add
class
to the element. The second parameter can be a single class name or an array of class names.Basic Usage:
Output:
Advanced Usage:
Output: