new $(Element_Setopt, contextopt) → {$}
- Source:
- See:
iQuery 对象构造函数
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
Element_Set
|
jQueryAcceptable |
<optional> |
|
context |
HTMLElement | object |
<optional> |
Selector context DOM or |
Returns:
Array-Like object
- Type
- $
Methods
(static) bitOperate(type, left, rightopt) → {number|string}
- Source:
- Version:
-
- 0.1
大数位操作
Example
// 按位或
$.bitOperate('|', '10'.repeat(16), '01'.repeat(16))
// '1'.repeat(32)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
type |
string |
|
|
left |
number | string |
Number may be big |
|
right |
number | string | <optional> |
Number may be big |
Returns:
- Type
- number | string
(static) buildFragment(node) → {DocumentFragment}
- Source:
构造文档片段
Parameters:
Name | Type | Description |
---|---|---|
node |
Node | ArrayLike |
Child Nodes |
Returns:
- Type
- DocumentFragment
(static) camelCase(raw) → {string}
- Source:
驼峰化字符串
Parameters:
Name | Type | Description |
---|---|---|
raw |
string |
Non Camel-Case String |
Returns:
- Type
- string
(static) cssRule(At_Wrapper, rule) → {HTMLStyleElement}
- Source:
全局 CSS 设置
Parameters:
Name | Type | Description |
---|---|---|
At_Wrapper |
string | At Rule |
rule |
object |
Selector as Key, Rule as Value |
Returns:
Generated Style Element
- Type
- HTMLStyleElement
(static) extendURL(URL, param) → {string}
- Source:
更新 URL 查询参数
Example
// 多种参数
$.extendURL('path/to/model?a=0', 'a=1&b=1', {b: 2, c: 3})
// 'path/to/model?a=1&b=2&c=3'
Parameters:
Name | Type | Description |
---|---|---|
URL |
string |
the URL needs to be updated |
param |
string | object |
One or more Query String or Object |
Returns:
the Updated URL
- Type
- string
(static) filePath(URLopt) → {string}
- Source:
获取文件路径
Examples
// 传 相对路径 时返回其目录
$.filePath('/test/unit.html') // '/test/'
// 传 查询字符串 时返回空字符串
$.filePath('?query=string') // ''
// 传 URL(字符串)时返回其目录
$.filePath('http://localhost:8084/test/unit.html')
// 'http://localhost:8084/test/'
// 传 URL(对象)时返回其目录
$.filePath(new URL('http://localhost:8084/test/unit.html'))
// 'http://localhost:8084/test/'
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
URL |
string | <optional> |
Relative or Absolute URL |
Returns:
- Type
- string
(static) hyphenCase(raw) → {string}
- Source:
连字符化字符串
Examples
// 符号间隔
$.hyphenCase('UPPER_CASE') // 'upper-case'
// 驼峰法
$.hyphenCase('camelCase') // 'camel-case'
// 混杂写法
$.hyphenCase('UPPER_CASEMix -camelCase')
// 'upper-case-mix-camel-case'
Parameters:
Name | Type | Description |
---|---|---|
raw |
string |
Non Hyphen-Case String |
Returns:
- Type
- string
(static) intersect(set) → {object|array}
- Source:
对象交集
Parameters:
Name | Type | Description |
---|---|---|
set |
object | array |
Returns:
Intersect of parameters
- Type
- object | array
(static) isEqual(left, right, depthopt) → {boolean}
- Source:
值相等 检测
Examples
// 基本类型比较
$.isEqual(1, 1) // true
// 引用类型(浅)
$.isEqual({a: 1}, {a: 1}) // true
// 引用类型(深)
$.isEqual({a: 1, b: {c: 2}}, {a: 1, b: {c: 2}}, 2) // true
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
left |
* | |||
right |
* | |||
depth |
number | <optional> |
1 |
Returns:
- Type
- boolean
(static) isXDomain(URL) → {boolean}
- Source:
URL 跨域判断
Examples
// 跨域 绝对路径
$.isXDomain('http://localhost/iQuery') // true
// 同域 相对路径
$.isXDomain('/iQuery') // false
Parameters:
Name | Type | Description |
---|---|---|
URL |
string |
Returns:
- Type
- boolean
(static) likeArray(object) → {boolean}
- Source:
类数组对象 检测
Examples
// 字符串元素不可变,故不是类数组
$.likeArray(new String('')) // false
// 有 length 属性、但没有对应数量元素的,不是类数组
$.likeArray({0: 'a', length: 2}) // false
// NodeList、HTMLCollection、jQuery 等是类数组
$.likeArray( document.head.childNodes ) // true
// Node 及其子类不是类数组
$.likeArray( document.createTextNode('') ) // false
Parameters:
Name | Type | Description |
---|---|---|
object |
object |
Returns:
- Type
- boolean
(static) makeIterator(array) → {Iterator}
- Source:
生成迭代器
Parameters:
Name | Type | Description |
---|---|---|
array |
Array |
Returns:
- Type
- Iterator
(static) makeSet(array, callbackopt) → {object}
- Source:
生成集合对象
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
array |
string | Array.<string> |
Keys of Set |
|
callback |
function | <optional> |
Callback for items |
Returns:
Set object (Not the one in ES 6)
- Type
- object
(static) mapTree(node, fork_key, filter) → {Array}
- Source:
对象树 递归遍历
Example
// DOM 树遍历
$.mapTree(
$('<a>A<b>B<!--C--></b></a>')[0],
'childNodes',
function (node, index, depth) {
return depth + (
(node.nodeType === 3) ? node.nodeValue : ''
);
}
).join('')
// '1A12B2'
Parameters:
Name | Type | Description |
---|---|---|
node |
object |
Object tree |
fork_key |
string |
Key of children list |
filter |
MapTreeFilter |
Map filter |
Returns:
Result list of Map filter
- Type
- Array
(static) paramJSON(searchopt) → {object}
- Source:
URL 查询参数对象化
Example
// URL 查询字符串
$.paramJSON('?a=1&b=two&b=true')
// {
a: 1,
b: ['two', true]
}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
search |
string | <optional> |
Same format as
|
Returns:
Plain Object for the Query String
- Type
- object
(static) parseHeader(raw) → {object}
- Source:
HTTP 报文头解析
Parameters:
Name | Type | Description |
---|---|---|
raw |
string |
Raw Text of HTTP Headers |
Returns:
Object of HTTP Headers
- Type
- object
(static) split(string, splitopt, maxopt, joinopt) → {Array.<string>}
- Source:
定字定数分割字符串
Examples
// 原型方法等效
$.split('abc', '') // ['a', 'b', 'c']
// PHP str_split() 等效
$.split('abc', '', 2) // ['a', 'bc']
// 连接字符串
$.split("a b\tc", /\s+/, 2, ' ') // ['a', 'b c']
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
string |
string |
Raw Text |
|
split |
string | RegExp | <optional> |
Separator to split as |
max |
number | <optional> |
Max number of returned parts |
join |
string | <optional> |
String to join |
Returns:
- Type
- Array.<string>
(static) storage(name, data) → {*}
- Source:
- Version:
-
- 0.1
本地存储 存取器
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
data |
* |
Returns:
Same as data
- Type
- *
(static) throttle(secondopt, origin) → {function}
- Source:
函数节流
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
second |
number | <optional> |
0.25 |
Minimum interval in second |
origin |
function |
Original function |
Returns:
Wrapped function
- Type
- function
(static) Type(object) → {string}
- Source:
检测对象类名
Parameters:
Name | Type | Description |
---|---|---|
object |
* |
Returns:
Class Name of the first argument
- Type
- string
(static) urlDomain(URLopt) → {string}
- Source:
获取 URL 的域(源)
Example
// 给定 URL
$.urlDomain('http://localhost:8080/path?query=string')
// 'http://localhost:8080'
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
URL |
string | <optional> |
Absolute URL |
Returns:
Origin of the URL
- Type
- string
(static) uuid(prefix) → {string}
- Source:
唯一标识符生成
Parameters:
Name | Type | Description |
---|---|---|
prefix |
string |
Returns:
- Type
- string
cssRule(ruleopt, callbackopt) → {object|$}
- Source:
局部 CSS 读写
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
rule |
object | <optional> |
Selector as Key, Rule as Value |
callback |
function | <optional> |
Callback for every HTMLElement |
Returns:
No parameter: CSS Rule Object\n
One or two: iQuery Object
- Type
- object | $
htmlExec(HTML, selectoropt) → {$}
- Source:
HTML 执行器
Examples
// 同步执行脚本
$('body').htmlExec(
"<script>self.test = $('body')[0].lastChild.tagName;</script>xxx"
) && self.test
// 'SCRIPT'
// CSS 选择符不执行脚本
$('body').htmlExec(
"<script>self.name = 'xxx';</script><a /><b />", 'script, a'
) && (
self.name + $('body')[0].children.length
)
// '2'
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
HTML |
string |
HTML source code with scripts executable |
|
selector |
string | <optional> |
CSS selector to filter |
Returns:
Element set of HTML source code
- Type
- $
insertTo($_Target, indexopt) → {$}
- Source:
任意索引位置 插入子节点
Examples
// 插入到最前
$('<a>insert</a>').insertTo('body') && (
$('body > :first-child')[0].textContent
)
// 'insert'
// 插入到最后
$('<a>insert</a>').insertTo('body', Infinity) && (
$('body > :last-child')[0].textContent
)
// 'insert'
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
$_Target |
jQueryAcceptable | |||
index |
number | <optional> |
0 |
Position index of
|
Returns:
All the Elements inserted
- Type
- $
validate() → {boolean}
- Source:
- See:
表单(项)校验
Returns:
- Type
- boolean