spinners

      <!-- loading -->

      <div id="loading" style="display:none;">

        <div class="spinner-border text-primary" role="status">

          <span class="visually-hidden">載入中...</span>

        </div>

        <span class="loader-text">資料載入中....</span>

      </div>


javascript

        function showLoading() {

          document.getElementById('loading').style.display = 'block';

        }


        function hideLoading() {

          document.getElementById('loading').style.display = 'none';

        }


這段程式碼使用了 HTML 和 Bootstrap 來建立一個載入指示器。載入指示器包含一個旋轉圖示和一條訊息,預設狀態下是隱藏的(style="display:none;")。當資料正在載入時,可以將 display 樣式更改為 block 來顯示載入指示器。

以下是程式碼的詳細說明:


JQuery


    <!-- loading

         $("#loading").show();

         $("#loading").hide();

    -->

    <div id="loading" style="display: none;">

      <div class="d-flex align-items-center">

        <div class="spinner-border text-primary me-2" role="status">

          <span class="visually-hidden">Loading...</span>

        </div>

        <div>資料處理中...</div>

      </div>

    </div>


指定「訂單送出」submit-order

      // loading start

      document.getElementById('submit-order').innerHTML = `<div class="d-flex align-items-center">

        <div class="spinner-border text-white me-2" role="status">

          <span class="visually-hidden">Loading...</span>

        </div>

        <div>資料處理中...</div>

      </div>`;