addClass

说明

获取DOM的特定属性值

源码

用法

addClass.test.ts
1
import { addClass } from "../../utility/dom/addClass";
2
3
describe('addClass', () => {
4
test('addClass should add the class to a DOM object', () => {
5
document.body.innerHTML = `
6
<div id="app" class="c1"></div>
7
`;
8
9
addClass(
10
(document.getElementById('app') as HTMLElement),
11
'c2',
12
);
13
14
expect((document.getElementById('app') as HTMLElement).classList.contains('c2')).toBeTruthy();
15
});
16
});
Copied!
最近更新 1yr ago
复制链接