jQuery 如何在 CodeIgniter 中使用日期选择器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33560450/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 16:57:42  来源:igfitidea点击:

How to use datepicker in CodeIgniter?

jquerycodeignitertwitter-bootstrap-3datepicker

提问by KaelJasper

why is it when i tried clicking the calendar icon for the datepicker, it wont pop up the calendar. I'm using this one bootstrap-datepicker. Here's the code:

为什么当我尝试单击日期选择器的日历图标时,它不会弹出日历。我正在使用这个bootstrap-datepicker。这是代码:

HTML

HTML

<div class="form-group">
   <label for="dob">Date of Birth</label>
      <div class="input-group date">
         <input type="text" class="form-control">
             <div class="input-group-addon">
                 <span class="glyphicon glyphicon-th"></span>
              </div>
      </div>
</div>

JS

JS

enter image description here

在此处输入图片说明

采纳答案by madalinivascu

Try:

尝试:

$('.input-group.date').datepicker({
});

jsfiddle : http://jsfiddle.net/1Lsfjdjf/

jsfiddle:http: //jsfiddle.net/1Lsfjdjf/

回答by Abdulla Nilam

In HTML

在 HTML 中

<input type="text" class="form-control form_datetime">

In JS

在JS中

<script type="text/javascript">
    $(".form_datetime").datetimepicker({format: 'yyyy-mm-dd hh:ii'});
</script> 

demo

演示

回答by Ram

Here is the example of datepicker

这是日期选择器的示例

  <?php echo form_input('date',$data['date'],array('class' => 'form- 
   control','id'=>'date')); ?>

try this

尝试这个

回答by piaworks

Here's what I did. I downloaded AdminLTE, copy the bower_components files where I found the datepicker css, js and bootstrap.

这就是我所做的。我下载了 AdminLTE,复制了我找到​​日期选择器 css、js 和引导程序的 bower_components 文件。

HTML file

HTML文件

<div class="form-group">
            <input type="text" class="form-control" placeholder="Preferred Date" id="birthpicker" required>
        </div>

I place this JS code below above of the body closing tag.

我将此 JS 代码放在正文结束标记的下方。

<script>
$(function () {
    $('#birthpicker').datepicker({
        autoclose: true
    })
})
</script>

That's it.

就是这样。