npm.io
2.1.5 • Published 2 years ago

@huangjs888/lightdom

Licence
MIT
Version
2.1.5
Deps
1
Size
161 kB
Vulns
0
Weekly
0

lightdom

一些dom操作

安装使用


npm install @huangjs888/lightdom --save
使用方法

import { createElement, setStyle, addClass, hasClass, removeClass } from '@huangjs888/lightdom';

const dom = createElement(
  {
    className: ['test', 'test2'],
    style: { width: 100, marginTop: 20 },
  },
  createElement('span', { style: { color: 'red' }, dataName: 'span element' }, 'Hello World'),
  document.body,
);
setStyle(addClass(removeClass(dom, 'test2'), 'test3'), { height: 100, marginLeft: 20 });
console.log(hasClass(dom, 'test2'));
console.log(hasClass(dom, 'test3'));

Keywords