dom-lib
DOM helper library
安装
npm install dom-lib --save
示例
import { addClass } from 'dom-lib';
API
Class
void hasClass(Element node, String className)
void addClass(Element node, String className)
void removeClass(Element node, String className)
void toggleClass(Element node, String className)
Style
String getStyle(Element node, String property)
Object getStyle(Element node)
String getComputedStyle(Element node, String property)
Object getComputedStyle(Element node)
void removeStyle(Element node, String property)
void removeStyle(Element node, Array propertys)
void addStyle(Element node, String property, String value)
void addStyle(Element node, Object style)
Events
Function on(Element target, String eventName, Function listener, Boolean capture = false)
Function onFocus()
void off(Element target, String eventName, Function listener, Boolean capture = false)
on 和 onFocus 方法将返回一个 off 函数, 用于方便解绑事件
Query
Element activeElement()
Number getHeight(Element node, client)
Number getWidth(Element node, client)
Object getOffset(Element node)
Object getOffsetParent(Element node)
Object getPosition(Element node, offsetParent)
String getWindow(Element node)
String nodeName(Element node)
Object ownerDocument(Element componentOrElement)
Object ownerWindow(Element componentOrElement)
void scrollLeft(Element node, Number val)
void scrollTop(Element node, Number val)