Make various corrections to notes

This commit is contained in:
Marcello 2021-07-12 16:18:53 +02:00
parent 411d740dd4
commit 23c1d6578f
16 changed files with 82 additions and 79 deletions

View file

@ -7,7 +7,7 @@ The document object is *globally available* in the browser. It allows to access
### Selecting Nodes from the DOM
`getElementById()` and `querySelector()` return a single element.
`getElementById()` and `querySelector()` return a single element.
`getElementsByClassName()`, `getElementsByTagName()`, and `querySelectorAll()` return a collection of elements.
```js
@ -16,14 +16,14 @@ Javascript
var node = document.getElementById('id');
// By Tag Name
var node = document.getElementsByTagName('tag');
var nodes = document.getElementsByTagName('tag');
// By Class Name
var node = document.getElementsByClassName('class');
var nodes = document.getElementsByClassName('class');
// By CSS Query
var node = document.querySelector('css-selector');
var node = document.querySelectorAll('css-selector');
var nodes = document.querySelectorAll('css-selector');
```
## Manupulating the DOM
@ -119,7 +119,7 @@ document.createTextNode('text');
domNode.appendChild(childToAppend); // insert childTaAppend after domNode
// insert node before domNode
domNode.insertBEfore(childToInsert, domnode);
domNode.insertBefore(childToInsert, domnode);
domNode.parentNode.insertBefore(childToInsert, nodeAfterChild);
// remove a node

View file

@ -63,6 +63,9 @@ window.setInterval(callbackFunction, delayMilliseconds);
//To stop an animation store the timer into a variable and clear it
window.clearTimeout(timer);
window.clearInterval(timer);
// execute a callback at each frame
window.requestAnimationFrame(callbackFunction);
```
### Element Position & dimensions

View file

@ -28,16 +28,15 @@
*/
```
### Naming Conventions
| Elements | Case |
| -------- | --------- |
| variable | camelCase |
### Modern Mode
If located at the top of the script the whole script works the “modern” way (enables post-ES5 functionalities).
`"use strict"`
```js
"use strict"
// script contents
```
### Pop-Up message
@ -328,8 +327,7 @@ if (condition) {
### Ternary Operator
`condition ? instruction1 : istruction2;`
Ff TRUE execute instruction1, execute instruction2 otherwise.
`condition ? <expr1> : <expr2>;`
### Switch Statement
@ -480,6 +478,7 @@ for(let key in dict) {
// do something with "key" and "value" variables
}
Object.keys(dict).forEach(key => { });
```
## Functions