diff --git a/snippets/hide.md b/snippets/hide.md new file mode 100644 index 000000000..e8024ddb9 --- /dev/null +++ b/snippets/hide.md @@ -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 elements on the page +``` diff --git a/snippets/show.md b/snippets/show.md new file mode 100644 index 000000000..c5b4e439b --- /dev/null +++ b/snippets/show.md @@ -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 elements on the page +``` diff --git a/tag_database b/tag_database index f170f51d9..f3f640e9c 100644 --- a/tag_database +++ b/tag_database @@ -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