Module

utils/dom/createelement

@ckeditor/ckeditor5-utils/src/dom/createelement

module

Filtering

Functions

  • createElement( doc, name, [ attributes ], [ children ] ) → Element

    Creates element with attributes and children.

    createElement( document, 'p' ); // <p>
    createElement( document, 'p', { class: 'foo' } ); // <p class="foo">
    createElement( document, 'p', null, 'foo' ); // <p>foo</p>
    createElement( document, 'p', null, [ 'foo', createElement( document, 'img' ) ] ); // <p>foo<img></p>

    Parameters

    doc : Document

    Document used to create element.

    name : String

    Name of the element.

    [ attributes ] : Object

    Object keys will become attributes keys and object values will became attributes values.

    [ children ] : Node | String | Array.<(Node | String)>

    Child or array of children. Strings will be automatically turned into Text nodes.

    Returns

    Element

    Created element.