国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Manual bahasa Cina Bootstrap / Bootstrap 按鈕

Bootstrap 按鈕

Bootstrap 按鈕(Button)插件

按鈕(Button)在 Bootstrap 按鈕 一章中介紹過。通過按鈕(Button)插件,您可以添加進一些交互,比如控制按鈕狀態(tài),或者為其他組件(如工具欄)創(chuàng)建按鈕組。

    如果您想要單獨引用該插件的功能,那么您需要引用 button.js。或者,正如 Bootstrap 插件概覽 一章中所提到,您可以引用 bootstrap.js 或壓縮版的 bootstrap.min.js。

加載狀態(tài)

如需向按鈕添加加載狀態(tài),只需要簡單地向 button 元素添加 data-loading-text="Loading..." 作為其屬性即可,如下面實例所示:

實例

<!DOCTYPE html>
<html>
<head>
   <title>Bootstrap 實例 - 按鈕(Button)插件加載狀態(tài)</title>
  <link href="http://libs.baidu.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="http://libs.baidu.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
</head>
<body>

<button id="fat-btn" class="btn btn-primary" data-loading-text="Loading..." 
   type="button"> 加載狀態(tài)
</button>
<script>
   $(function() { 
      $(".btn").click(function(){
         $(this).button('loading').delay(1000).queue(function() {
           // $(this).button('reset');
         });        
      });
   });  
</script>

</body>
</html>

運行實例 ?

點擊 "運行實例" 按鈕查看在線實例

單個切換

如需激活單個按鈕的切換(即改變按鈕的正常狀態(tài)為按壓狀態(tài),反之亦然),只需向 button 元素添加 data-toggle="button" 作為其屬性即可,如下面實例所示:

實例

<!DOCTYPE html>
<html>
<head>
   <title>Bootstrap 實例 - 按鈕(Button)插件單個切換</title>
  <link href="http://libs.baidu.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="http://libs.baidu.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
</head>
<body>

<button type="button" class="btn btn-primary" 
   data-toggle="button"> 單個切換
</button>

</body>
</html>

運行實例 ?

點擊 "運行實例" 按鈕查看在線實例

復(fù)選框(Checkbox)

您可以創(chuàng)建復(fù)選框組,并通過向 btn-group 添加 data 屬性 data-toggle="buttons" 來添加復(fù)選框組的切換。

實例

<!DOCTYPE html>
<html>
<head>
   <title>Bootstrap 實例 - 按鈕(Button)插件復(fù)選框</title>
   <link href="http://libs.baidu.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="http://libs.baidu.com/bootstrap/3.3.0/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>

運行實例 ?

點擊 "運行實例" 按鈕查看在線實例

單選按鈕(Radio)

類似地,您可以創(chuàng)建單選按鈕組,并通過向 btn-group 添加 data 屬性 data-toggle="buttons" 來添加單選按鈕組的切換。

實例

<!DOCTYPE html>
<html>
<head>
   <title>Bootstrap 實例 - 按鈕(Button)插件單選按鈕</title>
   <link href="http://libs.baidu.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="http://libs.baidu.com/bootstrap/3.3.0/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>

運行實例 ?

點擊 "運行實例" 按鈕查看在線實例

用法

您可以 通過 JavaScript 啟用按鈕(Button)插件,如下所示:

$('.btn').button()

選項

沒有選項。

方法

下面是一些按鈕(Button)插件中有用的方法:

方法描述實例
button('toggle')切換按壓狀態(tài)。賦予按鈕被激活的外觀。您可以使用 data-toggle 屬性啟用按鈕的自動切換。
$().button('toggle')
.button('loading')當(dāng)加載時,按鈕是禁用的,且文本變?yōu)?button 元素的 data-loading-text 屬性的值。
$().button('loading')
.button('reset')重置按鈕狀態(tài),文本內(nèi)容恢復(fù)為最初的內(nèi)容。當(dāng)您想要把按鈕返回為原始的狀態(tài)時,該方法非常有用。
$().button('reset')
.button(string)該方法中的字符串是指由用戶聲明的任何字符串。使用該方法,重置按鈕狀態(tài),并添加新的內(nèi)容。
$().button(string)

實例

下面的實例演示了上面方法的用法:

實例

<!DOCTYPE html>
<html>
<head>
   <title>Bootstrap 實例 - 按鈕(Button)插件方法</title>
   <link href="http://libs.baidu.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
  <script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
  <script src="http://libs.baidu.com/bootstrap/3.3.0/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>

運行實例 ?

點擊 "運行實例" 按鈕查看在線實例