From 2c96ce7cc1ae361b9b4c31efaa0cafeb83904718 Mon Sep 17 00:00:00 2001 From: Angelos Chalaris Date: Thu, 28 Dec 2017 23:33:21 +0200 Subject: [PATCH] Added show/hide snippets --- snippets/hide.md | 13 +++++++++++++ snippets/show.md | 13 +++++++++++++ tag_database | 2 ++ 3 files changed, 28 insertions(+) create mode 100644 snippets/hide.md create mode 100644 snippets/show.md 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