Methods
arrayToHtmlList(arr, label, listID)
- Source:
Example
arrayToHtmlList(['item 1', 'item 2'], 'li', 'app') // 在id为app元素下添加两个li列表
arrayToHtmlList(['item 1', 'item 2'], 'p', 'app') // 在id为app元素下添加两个p列表
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array | 目标数组 [元素内容] |
label |
String | 标签类型(p、list、div...) |
listID |
String | 添加到id为listID元素下 |
end()
- Source:
打印结束点
getStyle(el, ruleName) → {String}
- Source:
返回指定元素的生效样式
Example
getStyle(document.querySelector('p'), 'font-size'); // 16px
Parameters:
Name | Type | Description |
---|---|---|
el |
HTMLElement | |
ruleName |
String | css属性。如:font-size |
Returns:
- Type
- String
hide(el) → {*}
- Source:
如何隐藏所有指定的元素
Example
hide(document.querySelectorAll('p'))
Parameters:
Name | Type | Description |
---|---|---|
el |
HTMLElement |
Returns:
- Type
- *
insertAfter(el, htmlString, bORaopt) → {*}
- Source:
在指定元素之 前 / 后 插入新元素
Example
insertAfter(document.getElementById('msg'), '<p>我是insertAfter方法插入before的</p>', 'b'); // 在msg为id的元素,之前添加p标签
insertAfter(document.getElementById('msg'), '<p>我是insertAfter方法插入after的</p>', 'a'); // 在msg为id的元素,之后添加p标签
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
el |
HTMLElement | 指定元素 | ||
htmlString |
String | html标签 | ||
bORa |
string |
<optional> |
'b'
|
选择前后插入 b:之前beforebegin;a:之后afterend |
Returns:
- Type
- *
start()
- Source:
打印开始点