-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjavascript.code-snippets
More file actions
32 lines (32 loc) · 1.04 KB
/
javascript.code-snippets
File metadata and controls
32 lines (32 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
"Get element with its id by using getElementById() shortcut": {
"scope": "javascript",
"prefix": "get-id",
"body": "const ${1} = document.getElementById(\"${2}\");",
"description": "Get element with its id by using getElementById()"
},
"Get elements with its class name by using getElementsByClassName() shortcut": {
"scope": "javascript",
"prefix": "get-classes",
"body": "const ${1} = document.getElementsByClassName(\"${2}\");",
"description": "Get elements with its classes by using getElementsByClassName()"
},
"Get elements with its tag name by using getElementsByTagName() shortcut": {
"scope": "javascript",
"prefix": "get-tagNames",
"body": "const ${1} = document.getElementsByTagName(\"${2}\");",
"description": "Get elements with its tag name by using getElementsByTagName()"
},
"Using fetch API": {
"scope": "javascript",
"prefix": "mk-fetch",
"body": [
"fetch(${1})",
".then((res) => res.json())",
".then((data) => {\n\t\t${3}\n})",
".catch((err) => {",
"\t\tconsole.log(\"${2}\");",
"});"
]
}
}