document.getElementById(id)
: seleziona un elemento per il suoid
.document.getElementsByClassName(className)
: seleziona tutti gli elementi con una certa classe.document.getElementsByTagName(tagName)
: seleziona tutti gli elementi di un certo tag.document.querySelector(selector)
: seleziona il primo elemento che corrisponde a un selettore CSS.document.querySelectorAll(selector)
: seleziona tutti gli elementi che corrispondono a un selettore CSS.
- Scopo: Eseguire una funzione di callback per ogni elemento dell'array.
- Restituisce: undefined. Non restituisce un nuovo array.
- Utilizzo: Quando vuoi semplicemente eseguire un'azione per ogni elemento, senza bisogno di creare un nuovo array o di restituire un valore.
Esempio:
const numeri = [1, 2, 3, 4, 5];
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Bootstrap 4 all media queries #wMQ | |
* up > sm, md, lg, xl | |
* down < sm, md, lg | |
* only = xs, sm, lg, xl | |
* between <> sm-lg, sm-xl, md-xl | |
*/ | |
/* .xs = | Extra Small devices only (portrait phones) less than 576px */ |