Classname Operation
Published:
·
LastMod: November 18, 2021
·
73 words
操作相关classname工具函数
1
2
3
4
5
6
7
8
9
10
11
|
// 增加目标class
function addClass(target = '', srcCls = '') {
const clss = target.split(/\s+/)
return [...clss.filter(cls => !clss.includes(cls)), srcCls]
}
function removeClass(target = '', srcCls = '') {
const clss = target.split(/\s+/)
return [...clss.filter(cls => !clss.includes(srcCls))]
}
|