Jquery 无法使用引导日期选择器

Jquery 无法使用引导日期选择器,jquery,twitter-bootstrap,datepicker,bootstrap-datepicker,Jquery,Twitter Bootstrap,Datepicker,Bootstrap Datepicker,我试图添加输入区域,但无法对其进行配置: 我用他们生成的代码,并尝试了它,但似乎我错过了一些东西,请帮助我修复这个 <!DOCTYPE html> <html> <head> <title>Bootstrap</title> <meta name="viewport" content="width=device-width,initial-scale=1.0"> <

我试图添加输入区域,但无法对其进行配置:

我用他们生成的代码,并尝试了它,但似乎我错过了一些东西,请帮助我修复这个

<!DOCTYPE html>
<html>
    <head>
        <title>Bootstrap</title>
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <link href="../files/css/bootstrap.min.css" rel="stylesheet">
        <link href="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet">

        <script src="../files/js/jquery.min.js"></script>
        <script src="../files/js/bootstrap.js"></script>
        <script src="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    </head>
    <body>
        <div class="input-group date">
            <input type="text" class="form-control"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
        </div>

<script>
    $('#sandbox-container .input-group.date').datepicker({
        format: "yyyy/mm/dd",
        startDate: "2012-01-01",
        endDate: "2015-01-01",
        todayBtn: "linked",
        autoclose: true,
        todayHighlight: true
        });
</script>
    </body>
</html>

独自创立
$('#sandbox container.input group.date').datepicker({
格式:“yyyy/mm/dd”,
起始日期:“2012-01-01”,
截止日期:“2015-01-01”,
今日BTN:“链接”,
自动关闭:是的,
今天的亮点:真的
});

我还尝试使用和的链接:

在调用jQuery、bootstrap.js和bootstrap-datepicker.js之前,您正在调用datepicker函数。如果你调试它,你会得到一个异常,告诉你“datepicker”没有定义

相反,你应该写:

    <script src="../files/js/jquery.min"></script>
    <script src="../files/js/bootstrap.js"></script>
    <script src="http://eternicode.github.io/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>

    <script>
        $('#sandbox-container .input-group.date').datepicker({
             format: "yyyy/mm/dd",
             startDate: "2012-01-01",
             endDate: "2015-01-01",
             todayBtn: "linked",
             autoclose: true,
             todayHighlight: true
        });
    </script>

$('#sandbox container.input group.date').datepicker({
格式:“yyyy/mm/dd”,
起始日期:“2012-01-01”,
截止日期:“2015-01-01”,
今日BTN:“链接”,
自动关闭:是的,
今天的亮点:真的
});

将脚本移动到脚本上方的include标记,并从选择器中删除
#沙箱容器
——它不存在。之后它就可以工作了(使用正确的URL)


$('.input group.date').datepicker({
格式:“yyyy/mm/dd”,
起始日期:“2012-01-01”,
截止日期:“2015-01-01”,
今日BTN:“链接”,
自动关闭:是的,
今天的亮点:真的
});

您只需删除
#沙箱容器
,因为它不在您的代码中

试试这个:

<!DOCTYPE html>
<html>
    <head>
        <title>Bootstrap</title>
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <link href="../files/css/bootstrap.min.css" rel="stylesheet">
        <link href="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet">

        <script src="../files/js/jquery.min.js"></script>
        <script src="../files/js/bootstrap.js"></script>
        <script src="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    </head>
    <body>
        <div class="input-group date">
            <input type="text" class="form-control"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
        </div>

<script>
    $('.input-group.date').datepicker({
        format: "yyyy/mm/dd",
        startDate: "2012-01-01",
        endDate: "2015-01-01",
        todayBtn: "linked",
        autoclose: true,
        todayHighlight: true
    });
</script>
    </body>
</html>

独自创立
$('.input group.date').datepicker({
格式:“yyyy/mm/dd”,
起始日期:“2012-01-01”,
截止日期:“2015-01-01”,
今日BTN:“链接”,
自动关闭:是的,
今天的亮点:真的
});

我正在使用Bootstrap 3
http://eternicode.github.io/bootstrap-datepicker/js/bootstrap-datepicker.js
在链接中返回404 errorYes错误,但即使在正确链接后仍不工作请参阅更新您是否已尝试在
中包含
jquery
引导程序
等。在包含
bootstrap
library之前,您似乎正在尝试调用
datepicker
,已尝试但仍不工作请重试,您以前没有看到部分答案。引导日期选择器包含的404错误如何?
<!DOCTYPE html>
<html>
    <head>
        <title>Bootstrap</title>
        <meta name="viewport" content="width=device-width,initial-scale=1.0">
        <link href="../files/css/bootstrap.min.css" rel="stylesheet">
        <link href="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet">

        <script src="../files/js/jquery.min.js"></script>
        <script src="../files/js/bootstrap.js"></script>
        <script src="http://eternicode.github.io/bootstrap-datepicker/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    </head>
    <body>
        <div class="input-group date">
            <input type="text" class="form-control"><span class="input-group-addon"><i class="glyphicon glyphicon-th"></i></span>
        </div>

<script>
    $('.input-group.date').datepicker({
        format: "yyyy/mm/dd",
        startDate: "2012-01-01",
        endDate: "2015-01-01",
        todayBtn: "linked",
        autoclose: true,
        todayHighlight: true
    });
</script>
    </body>
</html>