diff --git a/README.md b/README.md index 3e9f2ee88..0c1b60618 100644 --- a/README.md +++ b/README.md @@ -1786,11 +1786,12 @@ copyToClipboard('Lorem ipsum'); // 'Lorem ipsum' copied to clipboard. ### createElement -Creates an element from a string. +Creates an element from a string (without appending it to the document). +If the given string contains multiple elements, only the first one will be returned. -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. +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 => { diff --git a/docs/index.html b/docs/index.html index 295d9e390..4e7fe2081 100644 --- a/docs/index.html +++ b/docs/index.html @@ -329,7 +329,7 @@ Object.assig } };
copyToClipboard('Lorem ipsum'); // 'Lorem ipsum' copied to clipboard. -
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.
const createElement = str => { +
Creates an element from a string (without appending it to the document). If the given string contains multiple elements, only the first one will be returned.
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.
const createElement = str => { const el = document.createElement('div'); el.innerHTML = str; return el.firstElementChild;