2015-09-12 106 views
0

我想引导日期选择器,但它不显示日历或它甚至不显示任何JavaScript错误,当我点击教科书。Bootstrap3日期选择器不起作用

下面是我显示日历的代码。

enter code here 
<!DOCTYPE html> 
<html lang="en"> 
<head> 
<meta charset="utf-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<meta name="viewport" content="width=device-width, initial-scale=1"> 

<!-- Bootstrap --> 
<link href="css/bootstrap-datepicker3.css" rel="stylesheet"> 

<script src="js/jquery.js"></script> 
<script src="js/bootstrap.min.js"></script>  

<!-- Date Picker --> 
<script src="js/bootstrap-datepicker.js"></script> 
</head> 
<body> 

<input type="text" class="form-control" id="sandbox-container"> 

<script> 
$(function() { 
$('#sandbox-container input').datepicker(); 
}); 
</script> 
</body> 
</html> 

回答

1

您的jQuery选择是错误的,应该只是$('#sandbox-container')

这应该是你的代码(包括工作示例):

$(function() { 
 
    $('#sandbox-container').datepicker({ 
 
     //.. 
 
    }); 
 
    
 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0/js/bootstrap-datepicker.js"></script> 
 
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet"/> 
 
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> 
 
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.4.0/css/bootstrap-datepicker3.css" rel="stylesheet"/> 
 
<input type="text" class="form-control" id="sandbox-container">

+0

非常感谢。它的工作,我也学到了:) –