Class

DomUtil

DomUtil()

Constructor

# new DomUtil()

dom结构工具类

Author:
  • xyj

Methods

# static addClass(el, name)

给当前节点添加一个className

Parameters:
Name Type Description
el string

节点

name string

类名

# static create(dom, className, container) → {Node}

创建dom

Parameters:
Name Type Description
dom string

dom标签

className string

类名

container string

包裹的容器

  • 创建的dom
Node

# static createSvg(width, height, path, container) → {SVGElement}

创建一个svg

Parameters:
Name Type Description
width string

height string

path string

svg化的路径

container string

插入svg的节点

  • svg
SVGElement

# static createVideo(url, className, container) → {Node}

创建video标签

Parameters:
Name Type Description
url string

音视频路径

className string

class名称

container string

要加入的容器

  • 返回创建的video结构
Node

# static empty(el)

清空当前节点内容

Parameters:
Name Type Description
el string

节点

# static enterFullscreen(el)

全屏化

Parameters:
Name Type Description
el

节点

# static exitFullscreen()

退出全屏

# static get(id) → {Node}

通过id获取当前dom元素

Parameters:
Name Type Description
id string

元素的id

  • 如果dom结构是字符串,则返回dom,否则原路返回
Node

# static getClass(el)

返回节点的类名

Parameters:
Name Type Description
el string

节点

# static getStyle(el, style) → {null|*}

返回元素上某个样式属性的值,包括计算值或通过CSS设置的值。

Parameters:
Name Type Description
el string

节点

style string

样式的key值

null | *

# static hasClass(el)

是否存在className

Parameters:
Name Type Description
el string

节点

# static parseDom(domStr, withWrapper, className) → {HTMLDivElement|NodeListOf.<ChildNode>}

将字符串转译成Element

Parameters:
Name Type Description
domStr string

需要转义的字符串

withWrapper string

是否给外层包一个元素

className string

类名

HTMLDivElement | NodeListOf.<ChildNode>

# static remove(el)

移除当前节点

Parameters:
Name Type Description
el string

节点

# static removeClass(el, name)

将指定类名从节点删除

Parameters:
Name Type Description
el string

节点

name string

类名

# static setClass(el, name)

给节点设置类名

Parameters:
Name Type Description
el string

节点

name string

类名