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

                                                                                                                                                          .appendToSync()

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

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

                                                                                                                                                          Syntax

                                                                                                                                                          $(el).appendToSync(target);

                                                                                                                                                          Parameters

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

                                                                                                                                                          Return

                                                                                                                                                          • this - The Play UI instance.

                                                                                                                                                          Usage

                                                                                                                                                          Append some dynamically-created nodes to document body.

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

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

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

                                                                                                                                                          Static Usage

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

                                                                                                                                                          Import

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

                                                                                                                                                          Syntax

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