|
1 | 1 | # Function `sel()`
|
2 |
| -**The last updated version of this function**: *2.0.0* |
| 2 | +**The last updated version of this function**: *3.1.0* |
3 | 3 | ## Browser Support
|
4 | 4 | | <img src="https://cdn.jsdelivr.net/gh/TechPot-Studio/svg-gallery/chrome.svg" width="30" /> | <img src="https://cdn.jsdelivr.net/gh/TechPot-Studio/svg-gallery/firefox.svg" width="30" /> | <img src="https://cdn.jsdelivr.net/gh/TechPot-Studio/svg-gallery/safari.svg" width="30" /> | <img src="https://cdn.jsdelivr.net/gh/TechPot-Studio/svg-gallery/opera.svg" width="30" /> | <img src="https://cdn.jsdelivr.net/gh/TechPot-Studio/svg-gallery/edge.svg" width="30" /> |
|
5 | 5 | | :---: | :---: | :---: | :---: | :---: |
|
|
8 | 8 | ```javascript
|
9 | 9 | peb.sel(selector, itemIndex)
|
10 | 10 | ```
|
11 |
| -| Parameter | Type | Optional | Description | |
12 |
| -| :---: | :---: | :---: | :---: | |
13 |
| -| selector | `String` | | Query Selector to element | |
14 |
| -| itemIndex | `Number` | Yes | Item Index in collection | |
15 |
| -## Properties |
16 |
| -### ID Selector or passed in `itemIndex` |
17 |
| -#### `.attr()` |
18 |
| -Get all attributes |
19 |
| -#### `.attr(sequence: object)` |
20 |
| -Change all \[key\] attributes to \[key value\] |
21 |
| -#### `.attr(name: string, value: string)` |
22 |
| - |
23 |
| -Change the attribute `name` to `value` when available, otherwise, return the attribute value corresponding to `name` |
24 |
| -#### `.data(name: string, value: string)` |
25 |
| - |
26 |
| -Change the dataset `name` to `value` when available, otherwise, return the dataset value corresponding to `name` |
27 |
| - |
28 |
| -#### `insert(...nodes: Node[] | HTMLElement[] | RElement[])` |
29 |
| -Add child elements to the object |
30 |
| - |
31 |
| -#### `del()` |
32 |
| -Remove Element |
33 |
| - |
34 |
| -#### `.html(value?: string)` |
35 |
| -Get it if no parameters are passed in, otherwise set value to `value` |
36 |
| - |
37 |
| -#### `.text()` |
38 |
| -Get innerText |
39 |
| - |
40 |
| -#### `.val(value?: string)` |
41 |
| -Get it if no parameters are passed in, otherwise set value to `value` |
42 |
| - |
43 |
| -#### `.hide()` |
44 |
| -Hide element |
45 |
| - |
46 |
| -#### `.show(type?: string) |
47 |
| -set value of `Element.style.display` if passed in parameter, otherwise set display type to value of lastest time hide |
48 |
| - |
49 |
| -#### `.on(event: string, listener?: function)` |
50 |
| -Add event listener if `listener` is passed in, otherwise remove |
51 |
| - |
52 |
| -#### `.class()` |
53 |
| -Returns HTMLSettableTokenList |
54 |
| - |
55 |
| -#### `.style(sheet)` |
56 |
| -Set style by sheet. sheet is a object like `{width: .5em}` |
57 |
| - |
58 |
| -#### `.next()` |
59 |
| -Get next element sibling |
60 |
| -#### `.prev()` |
61 |
| -Get previous element sibling |
62 |
| -#### `.parent()` |
63 |
| -Get parent |
64 |
| -#### `.child()` |
65 |
| -Get **first** child element |
66 |
| -*Tip:* Better effect with `.next()` |
| 11 | +### ID Selector or `itemIndex` |
| 12 | +[Reffer to `RElement`](cons-relement.md) |
67 | 13 |
|
68 | 14 | ### And Others
|
69 | 15 | #### `.forEach(callbackFn: function, startIndex: number)`
|
|
0 commit comments