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

                                                                                                                                                          .prependToSync()

                                                                                                                                                          This method is used to prepend matched elements to target elements.

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

                                                                                                                                                          Syntax

                                                                                                                                                          $(el).prependToSync(target);

                                                                                                                                                          Parameters

                                                                                                                                                          • target: String|Element - A CSS selector of the element, or the element itself Element, to prepend to.

                                                                                                                                                          Return

                                                                                                                                                          • this - The Play UI instance.

                                                                                                                                                          Usage

                                                                                                                                                          Prepend some dynamically-created nodes to document body.

                                                                                                                                                          $('<h1>Playful people!</h1>').prependToSync(document.body);

                                                                                                                                                          Prepend an existing div to multiple targets. The div is cloned into all targets except the last target.

                                                                                                                                                          let div = document.querySelector('div');
                                                                                                                                                          $(div).prependToSync('.multiple');

                                                                                                                                                          Static Usage

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

                                                                                                                                                          Import

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

                                                                                                                                                          Syntax

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