Merge pull request #377 from Chalarangelo/showhide

[FEATURE] Add show/hide snippets (browser)
This commit is contained in:
Angelos Chalaris
2017-12-29 00:10:10 +02:00
committed by GitHub
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.querySelectorAll('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.querySelectorAll('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