H50075:html中 书写 代码 code

1,

    <div class="col-12@sm">
      <h3>添加元素</h3>
      <p>无论您在DOM中添加元素的哪个位置,它都会显示在网格中(假设您使用默认的排序方式)。 考虑到这一点,您可以追加,前置或插入元素,以便让它们以正确的顺序显示。</p>
      
      <div class="code-block">
        <pre rel="JavaScript">
          <code class="language-javascript">
            Demo.prototype.setupEvents = function () {
              document.querySelector('#append').addEventListener('click', this.onAppendBoxes.bind(this));
            };

            /**
            * Create some DOM elements, append them to the shuffle container, then notify
            * shuffle about the new items. You could also insert the HTML as a string.
            */
            Demo.prototype.onAppendBoxes = function () {
              var elements = this._getArrayOfElementsToAdd();

              elements.forEach(function (element) {
                this.element.appendChild(element);
              }, this);

              // Tell shuffle elements have been appended.
              // It expects an array of elements as the parameter.
              this.shuffle.add(elements);
            };
          </code>
        </pre>
      </div>

 

posted @ 2021-04-22 10:06  琥珀君  阅读(176)  评论(0编辑  收藏  举报