Merge remote-tracking branch 'origin/master'
This commit is contained in:
48
README.md
48
README.md
@ -92,9 +92,11 @@
|
||||
* [`getScrollPosition`](#getscrollposition)
|
||||
* [`getURLParameters`](#geturlparameters)
|
||||
* [`hasClass`](#hasclass)
|
||||
* [`hide`](#hide)
|
||||
* [`httpsRedirect`](#httpsredirect)
|
||||
* [`redirect`](#redirect)
|
||||
* [`scrollToTop`](#scrolltotop)
|
||||
* [`show`](#show)
|
||||
* [`toggleClass`](#toggleclass)
|
||||
|
||||
</details>
|
||||
@ -1787,6 +1789,29 @@ hasClass(document.querySelector('p.special'), 'special'); // true
|
||||
[⬆ 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'));
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
hide(document.querySelectorAll('img')); // Hides all <img> elements on the page
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### httpsRedirect
|
||||
|
||||
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.
|
||||
@ -1863,6 +1888,29 @@ scrollToTop();
|
||||
[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### 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 = ''));
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
show(document.querySelectorAll('img')); // Shows all <img> elements on the page
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### toggleClass
|
||||
|
||||
Toggle a class for an element.
|
||||
|
||||
@ -161,9 +161,11 @@
|
||||
<a class="sublink-1" href="#getscrollposition">getScrollPosition</a>
|
||||
<a class="sublink-1" href="#geturlparameters">getURLParameters</a>
|
||||
<a class="sublink-1" href="#hasclass">hasClass</a>
|
||||
<a class="sublink-1" href="#hide">hide</a>
|
||||
<a class="sublink-1" href="#httpsredirect">httpsRedirect</a>
|
||||
<a class="sublink-1" href="#redirect">redirect</a>
|
||||
<a class="sublink-1" href="#scrolltotop">scrollToTop</a>
|
||||
<a class="sublink-1" href="#show">show</a>
|
||||
<a class="sublink-1" href="#toggleclass">toggleClass</a>
|
||||
|
||||
<h3>Date
|
||||
@ -868,6 +870,13 @@ Pass <code>location.search</code> as the argument to apply to the current <code>
|
||||
</code></pre>
|
||||
<pre><code class="language-js">hasClass(document.querySelector('p.special'), 'special'); // true
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="hide">hide</h3></div><div class="section double-padded">
|
||||
<p>Hides all the elements specified.</p>
|
||||
<p>Use the spread operator (<code>...</code>) and <code>Array.forEach()</code> to apply <code>display: none</code> to each element specified.</p>
|
||||
<pre><code class="language-js">const hide = (...el) => [...el].forEach(e => (e.style.display = 'none'));
|
||||
</code></pre>
|
||||
<pre><code class="language-js">hide(document.querySelectorAll('img')); // Hides all <img> elements on the page
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="httpsredirect">httpsRedirect</h3></div><div class="section double-padded">
|
||||
<p>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.</p>
|
||||
<p>Use <code>location.protocol</code> to get the protocol currently being used. If it's not HTTPS, use <code>location.replace()</code> to replace the existing page with the HTTPS version of the page. Use <code>location.href</code> to get the full address, split it with <code>String.split()</code> and remove the protocol part of the URL.</p>
|
||||
@ -898,6 +907,13 @@ Scroll by a fraction of the distance from the top. Use <code>window.requestAnima
|
||||
</code></pre>
|
||||
<pre><code class="language-js">scrollToTop();
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="show">show</h3></div><div class="section double-padded">
|
||||
<p>Shows all the elements specified.</p>
|
||||
<p>Use the spread operator (<code>...</code>) and <code>Array.forEach()</code> to clear the <code>display</code> property for each element specified.</p>
|
||||
<pre><code class="language-js">const show = (...el) => [...el].forEach(e => (e.style.display = ''));
|
||||
</code></pre>
|
||||
<pre><code class="language-js">show(document.querySelectorAll('img')); // Shows all <img> elements on the page
|
||||
</code></pre>
|
||||
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="toggleclass">toggleClass</h3></div><div class="section double-padded">
|
||||
<p>Toggle a class for an element.</p>
|
||||
<p>Use <code>element.classList.toggle()</code> to toggle the specified class for the element.</p>
|
||||
|
||||
13
snippets/hide.md
Normal file
13
snippets/hide.md
Normal 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
13
snippets/show.md
Normal 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
|
||||
```
|
||||
@ -57,6 +57,7 @@ hammingDistance:math
|
||||
hasClass:browser
|
||||
head:array
|
||||
hexToRGB:utility
|
||||
hide:browser
|
||||
httpsRedirect:browser
|
||||
initial:array
|
||||
initialize2DArray:array
|
||||
@ -112,6 +113,7 @@ scrollToTop:browser
|
||||
sdbm:utility
|
||||
select:object
|
||||
shallowClone:object
|
||||
show:browser
|
||||
shuffle:array
|
||||
similarity:array
|
||||
sleep:function
|
||||
|
||||
Reference in New Issue
Block a user