<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                # Bootstrap 按鈕(Button)插件 按鈕(Button)在 [Bootstrap 按鈕](bootstrap-buttons.html) 一章中介紹過。通過按鈕(Button)插件,您可以添加進一些交互,比如控制按鈕狀態,或者為其他組件(如工具欄)創建按鈕組。 > ![](https://box.kancloud.cn/2015-12-18_5673d62a0b3b4.png)如果您想要單獨引用該插件的功能,那么您需要引用 **button.js**。或者,正如 [Bootstrap 插件概覽](bootstrap-plugins-overview.html) 一章中所提到,您可以引用 _bootstrap.js_ 或壓縮版的 _bootstrap.min.js_。 ## 加載狀態 如需向按鈕添加加載狀態,只需要簡單地向 button 元素添加 **data-loading-text="Loading..."** 作為其屬性即可,如下面實例所示: ``` <!DOCTYPE html> <html> <head> <title>Bootstrap 實例 - 按鈕(Button)插件加載狀態</title> <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <script src="/scripts/jquery.min.js"></script> <script src="/bootstrap/js/bootstrap.min.js"></script> </head> <body> <button id="fat-btn" class="btn btn-primary" data-loading-text="Loading..." type="button"> 加載狀態 </button> <script> $(function() { $(".btn").click(function(){ $(this).button('loading').delay(1000).queue(function() { // $(this).button('reset'); }); }); }); </script> </body> </html> ``` [](/try/tryit.php?filename=bootstrap3-plugin-button-loadingstate) 結果如下所示: ![按鈕(Button)插件加載狀態](https://box.kancloud.cn/2015-12-18_5673d65d9fb0a.jpg) ## 單個切換 如需激活單個按鈕的切換(即改變按鈕的正常狀態為按壓狀態,反之亦然),只需向 button 元素添加 **data-toggle="button"** 作為其屬性即可,如下面實例所示: ``` <!DOCTYPE html> <html> <head> <title>Bootstrap 實例 - 按鈕(Button)插件單個切換</title> <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <script src="/scripts/jquery.min.js"></script> <script src="/bootstrap/js/bootstrap.min.js"></script> </head> <body> <button type="button" class="btn btn-primary" data-toggle="button"> 單個切換 </button> </body> </html> ``` [](/try/tryit.php?filename=bootstrap3-plugin-button-sinlgetoggle) 結果如下所示: ![按鈕(Button)插件單個切換](https://box.kancloud.cn/2015-12-18_5673d65dabf83.jpg) ## 復選框(Checkbox) 您可以創建復選框組,并通過向 **btn-group** 添加 data 屬性 **data-toggle="buttons"** 來添加復選框組的切換。 ``` <!DOCTYPE html> <html> <head> <title>Bootstrap 實例 - 按鈕(Button)插件復選框</title> <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <script src="/scripts/jquery.min.js"></script> <script src="/bootstrap/js/bootstrap.min.js"></script> </head> <body> <div class="btn-group" data-toggle="buttons"> <label class="btn btn-primary"> <input type="checkbox"> 選項 1 </label> <label class="btn btn-primary"> <input type="checkbox"> 選項 2 </label> <label class="btn btn-primary"> <input type="checkbox"> 選項 3 </label> </div> </body> </html> ``` [](/try/tryit.php?filename=bootstrap3-plugin-button-checkbox) 結果如下所示: ![按鈕(Button)插件復選框](https://box.kancloud.cn/2015-12-18_5673d65dda24e.jpg) ## 單選按鈕(Radio) 類似地,您可以創建單選按鈕組,并通過向 **btn-group** 添加 data 屬性 **data-toggle="buttons"** 來添加單選按鈕組的切換。 ``` <!DOCTYPE html> <html> <head> <title>Bootstrap 實例 - 按鈕(Button)插件單選按鈕</title> <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <script src="/scripts/jquery.min.js"></script> <script src="/bootstrap/js/bootstrap.min.js"></script> </head> <body> <div class="btn-group" data-toggle="buttons"> <label class="btn btn-primary"> <input type="radio" name="options" id="option1"> 選項 1 </label> <label class="btn btn-primary"> <input type="radio" name="options" id="option2"> 選項 2 </label> <label class="btn btn-primary"> <input type="radio" name="options" id="option3"> 選項 3 </label> </div> </body> </html> ``` [](/try/tryit.php?filename=bootstrap3-plugin-button-radio) 結果如下所示: ![按鈕(Button)插件單選按鈕](https://box.kancloud.cn/2015-12-18_5673d65de7155.jpg) ## 用法 您可以 **通過 JavaScript** 啟用按鈕(Button)插件,如下所示: ``` $('.btn').button() ``` ## 選項 _沒有選項。_ ## 方法 下面是一些按鈕(Button)插件中有用的方法: | 方法 | 描述 | 實例 | | --- | --- | --- | | button('toggle') | 切換按壓狀態。賦予按鈕被激活的外觀。您可以使用 **data-toggle** 屬性啟用按鈕的自動切換。 | `$().button('toggle')` | | .button('loading') | 當加載時,按鈕是禁用的,且文本變為 button 元素的 **data-loading-text** 屬性的值。 | `$().button('loading')` | | .button('reset') | 重置按鈕狀態,文本內容恢復為最初的內容。當您想要把按鈕返回為原始的狀態時,該方法非常有用。 | `$().button('reset')` | | .button(string) | 該方法中的字符串是指由用戶聲明的任何字符串。使用該方法,重置按鈕狀態,并添加新的內容。 | `$().button(string)` | ### 實例 下面的實例演示了上面方法的用法: ``` <!DOCTYPE html> <html> <head> <title>Bootstrap 實例 - 按鈕(Button)插件方法</title> <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <script src="/scripts/jquery.min.js"></script> <script src="/bootstrap/js/bootstrap.min.js"></script> </head> <body> <h2>點擊每個按鈕查看方法效果</h2> <h4>演示 .button('toggle') 方法</h4> <div id="myButtons1" class="bs-example"> <button type="button" class="btn btn-primary">原始</button> </div> <h4>演示 .button('loading') 方法</h4> <div id="myButtons2" class="bs-example"> <button type="button" class="btn btn-primary" data-loading-text="Loading...">原始 </button> </div> <h4>演示 .button('reset') 方法</h4> <div id="myButtons3" class="bs-example"> <button type="button" class="btn btn-primary" data-loading-text="Loading...">原始 </button> </div> <h4>演示 .button(string) 方法</h4> <button type="button" class="btn btn-primary" id="myButton4" data-complete-text="Loading finished">請點擊我 </button> <script type="text/javascript"> $(function () { $("#myButtons1 .btn").click(function(){ $(this).button('toggle'); }); }); $(function() { $("#myButtons2 .btn").click(function(){ $(this).button('loading').delay(1000).queue(function() { }); }); }); $(function() { $("#myButtons3 .btn").click(function(){ $(this).button('loading').delay(1000).queue(function() { $(this).button('reset'); }); }); }); $(function() { $("#myButton4").click(function(){ $(this).button('loading').delay(1000).queue(function() { $(this).button('complete'); }); }); }); </script> </body> </html> ``` [](/try/tryit.php?filename=bootstrap3-plugin-button-method) 結果如下所示: ![按鈕(Button)插件方法](https://box.kancloud.cn/2015-12-18_5673d65e217ed.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看