diff --git a/README.md b/README.md
index 46f01c489..bfaf1e8bc 100644
--- a/README.md
+++ b/README.md
@@ -91,9 +91,11 @@
* [`elementIsVisibleInViewport`](#elementisvisibleinviewport)
* [`getScrollPosition`](#getscrollposition)
* [`getURLParameters`](#geturlparameters)
+* [`hide`](#hide)
* [`httpsRedirect`](#httpsredirect)
* [`redirect`](#redirect)
* [`scrollToTop`](#scrolltotop)
+* [`show`](#show)
@@ -1762,6 +1764,29 @@ getURLParameters('http://url.com/page?name=Adam&surname=Smith'); // {name: 'Adam
[⬆ Back to top](#table-of-contents)
+### 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'));
+```
+
+Examples
+
+```js
+hide(document.querySelectorAll('img')); // Hides all elements on the page
+```
+
+
Examples
+
+```js
+show(document.querySelectorAll('img')); // Shows all elements on the page
+```
+
+
location.search as the argument to apply to the current
getURLParameters('http://url.com/page?name=Adam&surname=Smith'); // {name: 'Adam', surname: 'Smith'}
+Hides all the elements specified.
+Use the spread operator (...) and Array.forEach() to apply display: none to each element specified.
const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
+
+hide(document.querySelectorAll('img')); // Hides all <img> elements on the page
+
Redirects the page to HTTPS if its currently in HTTP. Also, pressing the back button doesn't take it back to the HTTP page as its replaced in the history.
Use location.protocol to get the protocol currently being used. If it's not HTTPS, use location.replace() to replace the existing page with the HTTPS version of the page. Use location.href to get the full address, split it with String.split() and remove the protocol part of the URL.
window.requestAnima
scrollToTop();
+Shows all the elements specified.
+Use the spread operator (...) and Array.forEach() to clear the display property for each element specified.
const show = (...el) => [...el].forEach(e => (e.style.display = ''));
+
+show(document.querySelectorAll('img')); // Shows all <img> elements on the page
+
Returns the difference (in days) between two dates.
diff --git a/snippets/hide.md b/snippets/hide.md index b19486df4..82a02a4b0 100644 --- a/snippets/hide.md +++ b/snippets/hide.md @@ -5,7 +5,7 @@ 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'); +const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); ``` ```js diff --git a/snippets/show.md b/snippets/show.md index 2e2302d19..cf30be9b7 100644 --- a/snippets/show.md +++ b/snippets/show.md @@ -5,7 +5,7 @@ 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 = ''); +const show = (...el) => [...el].forEach(e => (e.style.display = '')); ``` ```js