> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/browser/dom/type/node/+ext/newelement.md).

# newElement()

{% tabs %}
{% tab title="💾 程式" %}
:floppy\_disk: replit: [elem.showNote()](https://replit.com/@pegasusroe/elemshowNote#script.js)

```javascript
// ⭐️ newElement()
/*
 * create and configure a new Element
 * 
 * @param {string}   tagName  - like 'div', 'span' ...
 * @param {function} config   - function to configure the newly created element
 * @return {Element}
 */
function newElement(tagName, config) {
    let elem = document.createElement(tagName);
    if (config) { config(elem) }
    return elem;
}
```

{% endtab %}

{% tab title="📗 參考" %}

* [x] JS.info ⟩ [Show a note near the element](https://tr.javascript.info/coordinates#show-a-note-near-the-element)
  {% endtab %}

{% tab title="📘 手冊" %}

* [Document](/web/browser/dom/type/document.md) ⟩ [.createElement()](https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement)
  {% endtab %}
  {% endtabs %}
