Merge remote-tracking branch 'origin/master'
This commit is contained in:
13
snippets/hide.md
Normal file
13
snippets/hide.md
Normal file
@ -0,0 +1,13 @@
|
||||
### hide
|
||||
|
||||
Hides all the elements specified.
|
||||
|
||||
Use the spread operator (`...`) and `Array.forEach()` to apply `display: none` to each element specified.
|
||||
|
||||
```js
|
||||
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
|
||||
```
|
||||
|
||||
```js
|
||||
hide(document.querySelectorAll('img')); // Hides all <img> elements on the page
|
||||
```
|
||||
13
snippets/show.md
Normal file
13
snippets/show.md
Normal file
@ -0,0 +1,13 @@
|
||||
### show
|
||||
|
||||
Shows all the elements specified.
|
||||
|
||||
Use the spread operator (`...`) and `Array.forEach()` to clear the `display` property for each element specified.
|
||||
|
||||
```js
|
||||
const show = (...el) => [...el].forEach(e => (e.style.display = ''));
|
||||
```
|
||||
|
||||
```js
|
||||
show(document.querySelectorAll('img')); // Shows all <img> elements on the page
|
||||
```
|
||||
Reference in New Issue
Block a user