Pages
    • GETTING STARTED
        • API REFERENCE
                                                                                                                                              • COMMAND LINE
                                                                                                                                                  On this page

                                                                                                                                                          .prependAsync()

                                                                                                                                                          This method is used to asynchronously prepend content to an element. It works exactly the same as the native ParentNode.prepend() except that when the implied content is undefined, it is converted to an empty string.

                                                                                                                                                          The suffix Async differentiates this method from its Sync counterpart - .prependSync(). Unlike the Sync counterpart, this method is promised-based. See Async UI.

                                                                                                                                                          Syntax

                                                                                                                                                          // Prepend content(s) to an element
                                                                                                                                                          await $(el).prependAsync(content[, ...content]);

                                                                                                                                                          Parameters

                                                                                                                                                          • content: String|Node - The text or HTML content, or some DOM node, to prepend.

                                                                                                                                                          Return

                                                                                                                                                          • this - The Play UI instance.

                                                                                                                                                          Usage

                                                                                                                                                          Prepend an element node and some text content to an element.

                                                                                                                                                          let div = document.createElement("div");
                                                                                                                                                          $(el).prependAsync('!', 'people', ' ', 'Playful', div);

                                                                                                                                                          Static Usage

                                                                                                                                                          The .prependAsync() instance method is internally based on the standalone dom/appendAsync() function which may be used statically.

                                                                                                                                                          Import

                                                                                                                                                          const { prependAsync } = $.dom;
                                                                                                                                                          import { prependAsync } from '@webqit/playui-js/src/dom/index.js';

                                                                                                                                                          Syntax

                                                                                                                                                          See the general way to use Play UI's standalone functions