Travis build: 1053
This commit is contained in:
34
README.md
34
README.md
@ -144,6 +144,7 @@ average(1, 2, 3);
|
||||
* [`arrayToHtmlList`](#arraytohtmllist)
|
||||
* [`bottomVisible`](#bottomvisible)
|
||||
* [`copyToClipboard`](#copytoclipboard-)
|
||||
* [`createElement`](#createelement)
|
||||
* [`currentURL`](#currenturl)
|
||||
* [`detectDeviceType`](#detectdevicetype)
|
||||
* [`elementIsVisibleInViewport`](#elementisvisibleinviewport)
|
||||
@ -1783,6 +1784,39 @@ copyToClipboard('Lorem ipsum'); // 'Lorem ipsum' copied to clipboard.
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### createElement
|
||||
|
||||
Creates an element from a string.
|
||||
|
||||
Use `document.createElement()` to create a new element. Set its `innerHTML`
|
||||
to the string supplied as the argument. Use `ParentNode.firstElementChild` to
|
||||
return the element version of the string.
|
||||
|
||||
```js
|
||||
const createElement = str => {
|
||||
const el = document.createElement('div');
|
||||
el.innerHTML = str;
|
||||
return el.firstElementChild;
|
||||
};
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
const el = createElement(
|
||||
`<div class="container">
|
||||
<p>Hello!</p>
|
||||
</div>`
|
||||
);
|
||||
console.log(el.className); // 'container'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### currentURL
|
||||
|
||||
Returns the current URL.
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user