0

我找到bootstrap-select,但我無法獲得一個很好的下拉菜單here。我可以在哪裏做任何錯誤?bootstrap-select沒有任何效果

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
<meta charset="utf-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<meta name="description" content=""> 
<meta name="author" content=""> 

<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png"> 

<title>Test</title> 

<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" > 
<link rel="stylesheet" type="text/css" href=//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.2/css/bootstrap-select.min.css> 
<link href="http://getbootstrap.com/examples/non-responsive/non-responsive.css" rel="stylesheet"> 

    </head> 

    <body> 

<div class="container"> 
    <form class="form-inline"> 
    <div class="form-group"> 
     <label class="col-md-1 control-label" for="lunch">Lunch: </label> 
    </div> 
    <div class="form-group"> 
     <select id="lunch" class="selectpicker" data-live-search="true" title="Please select a lunch ..."> 
    <option>Hot Dog, Fries and a Soda</option> 
    <option>Burger, Shake and a Smile</option> 
    <option>Sugar, Spice and all things nice</option> 
    <option>Baby Back Ribs</option> 
    <option>A really really long option made to illustrate an issue with the live search in an inline form</option> 
     </select> 
    </div> 
    </form> 
<div> 

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> 
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> 
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.2/js/bootstrap-select.min.js"></script> 

    </body> 
</html> 
+0

獲取任何控制檯錯誤? – 2014-09-26 06:24:16

+0

不,我沒有用javascript調用select(請參閱下面的解決方案)。 – user977828 2014-09-26 07:06:16

回答

1

您不是用javascript調用select。改用此代碼。

<!DOCTYPE html> 
<html lang="en"> 
    <head> 
<meta charset="utf-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<meta name="description" content=""> 
<meta name="author" content=""> 

<link rel="shortcut icon" href="../../docs-assets/ico/favicon.png"> 

<title>Test</title> 

<link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" > 
<link rel="stylesheet" type="text/css" href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.2/css/bootstrap-select.min.css"> 
<link href="http://getbootstrap.com/examples/non-responsive/non-responsive.css" rel="stylesheet"> 

    </head> 

    <body> 

<div class="container"> 
    <form class="form-inline"> 
    <div class="form-group"> 
     <label class="col-md-1 control-label" for="lunch">Lunch: </label> 
    </div> 
    <div class="form-group"> 
     <select id="lunch" class="selectpicker" data-live-search="true" title="Please select a lunch ..."> 
    <option>Hot Dog, Fries and a Soda</option> 
    <option>Burger, Shake and a Smile</option> 
    <option>Sugar, Spice and all things nice</option> 
    <option>Baby Back Ribs</option> 
    <option>A really really long option made to illustrate an issue with the live search in an inline form</option> 
     </select> 
    </div> 
    </form> 
<div> 

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script> 
<script type="text/javascript" src="//netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> 
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.6.2/js/bootstrap-select.min.js"></script> 
<script> 
$('.selectpicker').selectpicker(); 
</script> 
    </body> 
</html>