Travis build: 1055
This commit is contained in:
@ -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 => {
|
||||
|
||||
@ -329,7 +329,7 @@ Object<span class="token punctuation">.</span><span class="token function">assig
|
||||
}
|
||||
};</span>
|
||||
</pre><label class="collapse">Show examples</label><pre class="language-js"><span class="token function">copyToClipboard</span><span class="token punctuation">(</span><span class="token string">'Lorem ipsum'</span><span class="token punctuation">);</span> <span class="token comment">// 'Lorem ipsum' copied to clipboard.</span>
|
||||
</pre><button class="primary clipboard-copy"><img src="clipboard.svg" alt="clipboard"> Copy to clipboard</button></div></div><div class="card fluid"><h3 id="createelement" class="section double-padded">createElement</h3><div class="section double-padded"><p>Creates an element from a string.</p><p>Use <code>document.createElement()</code> to create a new element. Set its <code>innerHTML</code> to the string supplied as the argument. Use <code>ParentNode.firstElementChild</code> to return the element version of the string.</p><pre class="language-js"><span class="token keyword">const</span> <span class="token function-variable function">createElement</span> <span class="token operator">=</span> str <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||||
</pre><button class="primary clipboard-copy"><img src="clipboard.svg" alt="clipboard"> Copy to clipboard</button></div></div><div class="card fluid"><h3 id="createelement" class="section double-padded">createElement</h3><div class="section double-padded"><p>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.</p><p>Use <code>document.createElement()</code> to create a new element. Set its <code>innerHTML</code> to the string supplied as the argument. Use <code>ParentNode.firstElementChild</code> to return the element version of the string.</p><pre class="language-js"><span class="token keyword">const</span> <span class="token function-variable function">createElement</span> <span class="token operator">=</span> str <span class="token operator">=></span> <span class="token punctuation">{</span>
|
||||
<span class="token keyword">const</span> el <span class="token operator">=</span> document<span class="token punctuation">.</span><span class="token function">createElement</span><span class="token punctuation">(</span><span class="token string">'div'</span><span class="token punctuation">);</span>
|
||||
el<span class="token punctuation">.</span>innerHTML <span class="token operator">=</span> str<span class="token punctuation">;</span>
|
||||
<span class="token keyword">return</span> el<span class="token punctuation">.</span>firstElementChild<span class="token punctuation">;
|
||||
|
||||
Reference in New Issue
Block a user