Added show/hide snippets

This commit is contained in:
Angelos Chalaris
2017-12-28 23:33:21 +02:00
parent 0d9d8edf2c
commit 5977cf6bcb
3 changed files with 28 additions and 0 deletions

13
snippets/hide.md Normal file
View 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.querySelector('img')); // Hides all <img> elements on the page
```

13
snippets/show.md Normal file
View 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.querySelector('img')); // Shows all <img> elements on the page
```

View File

@ -56,6 +56,7 @@ groupBy:array
hammingDistance:math
head:array
hexToRGB:utility
hide:browser
httpsRedirect:browser
initial:array
initialize2DArray:array
@ -111,6 +112,7 @@ scrollToTop:browser
sdbm:utility
select:object
shallowClone:object
show:browser
shuffle:array
similarity:array
sleep:function