jquery – bootstrap datepicker语言环境/语言不起作用

JS和css添加 –

<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="css/css.css">
<link rel="shortcut icon" href="foto/logo.png" />
<link href='css/hover.css' rel='stylesheet' media='all'>

<script src="script/jquery.min.js"></script>
<script src="script/script.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/locales/bootstrap-datepicker.id.min.js" charset="UTF-8"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker3.css"/>

Javascript代码 –

<script>
$(document).ready(function(){
  var date_input=$('input[name="datepicker"]'); //our date input has the name "date"
  var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
  var options={
    format: 'dd-mm-yyyy',
    container: container,
    todayHighlight: true,
    autoclose: true, 
    daysOfWeekDisabled: "0",
    daysOfWeekHighlighted: "0",
    language: "id",
    locale: "id",
  };
  date_input.datepicker({options});
})
</script>

HTML的

<input class="form-control" id="date" name="datepicker" placeholder=" -- (tahun/bulan/tanggal) -- " type="text"/>

bootstrap datepicker locale / languange不起作用
我错过了什么吗?
bootstrap datepicker locale / languange不起作用
我错过了什么吗?
bootstrap datepicker locale / languange不起作用
我错过了什么?bootstrap datepicker locale / languange不起作用
我错过了什么吗?

最佳答案 您缺少jquery.js和bootstrap.min.css,并且以下行中还存在语法错误:

date_input.datepicker({options});

它应该是:

date_input.datepicker(options); 

试试以下工作演示:

$(document).ready(function(){
 var date_input=$('input[name="datepicker"]'); //our date input has the name "date"
  var container=$('.bootstrap-iso form').length>0 ? $('.bootstrap-iso form').parent() : "body";
  var options={
    format: 'dd-mm-yyyy',
    container: container,
    todayHighlight: true,
    autoclose: true, 
    daysOfWeekDisabled: "0",
    daysOfWeekHighlighted: "0",
    language: "id",
    locale: "id",
  };
  date_input.datepicker(options);  
});
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/js/bootstrap-datepicker.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/locales/bootstrap-datepicker.id.min.js" charset="UTF-8"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.6.4/css/bootstrap-datepicker3.css"/>
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"/>

<input class="form-control" id="date" name="datepicker" placeholder=" -- (tahun/bulan/tanggal) -- " type="text"/>
点赞