Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何通过图标激活引导日期选择器_Jquery_Twitter Bootstrap_Bootstrap Datepicker - Fatal编程技术网

Jquery 如何通过图标激活引导日期选择器

Jquery 如何通过图标激活引导日期选择器,jquery,twitter-bootstrap,bootstrap-datepicker,Jquery,Twitter Bootstrap,Bootstrap Datepicker,如何通过单击图标激活引导日期选择器 我的HTML代码是: <input type="text" class="datepicker"> <span class="add-on"><i class="icon-calendar" id="cal2"></i></span> 剧本是: <script> $(function(){ $('.datepicker').datepicker({

如何通过单击图标激活引导日期选择器

我的HTML代码是:

<input type="text" class="datepicker">  
    <span class="add-on"><i class="icon-calendar" id="cal2"></i></span>

剧本是:

<script>
$(function(){
    $('.datepicker').datepicker({
        format: 'mm-dd-yyyy',
        endDate: '+0d',
        autoclose: true
    });
});
</script>

$(函数(){
$('.datepicker').datepicker({
格式:“mm dd yyyy”,
结束日期:“+0d”,
自动关闭:正确
});
});
我想通过点击图标激活我的日期选择器,但它不起作用

我如何才能做到这一点?


<script>
$(function(){
    $('.datepicker').datepicker({
        format: 'mm-dd-yyyy',
        endDate: '+0d',
        autoclose: true,
        showOn: "button",
        buttonImage: "images/calendar.gif",
        buttonImageOnly: true
    });
});
</script>
$(函数(){ $('.datepicker').datepicker({ 格式:“mm dd yyyy”, 结束日期:“+0d”, 自动关闭:是的, 展示:“按钮”, buttonImage:“images/calendar.gif”, buttonImageOnly:true }); });
根据文档:

.datepicker('show')显示日期选择器

<input type="text" id="my-datepicker" class="datepicker">  
<span class="add-on"><i class="icon-calendar" id="cal2"></i></span>

<script type="text/javascript">"
   $('#cal2').click(function(){
       $(document).ready(function(){
           $("#my-datepicker").datepicker().focus();
       });
   });
</script>
只需使用单击事件来显示日期选择器。


<input type="text" id="my-datepicker" class="datepicker">  
<span class="add-on"><i class="icon-calendar" id="cal2"></i></span>

<script type="text/javascript">"
   $('#cal2').click(function(){
       $(document).ready(function(){
           $("#my-datepicker").datepicker().focus();
       });
   });
</script>
" $('#cal2')。单击(函数(){ $(文档).ready(函数(){ $(“#我的日期选择器”).datepicker().focus(); }); });
从中,将日期选择器
文本框
div

<div class="input-append date" id="dp3">
    <input type="text" id="datepicker" /> 
       <span class="add-on"><i class="icon-calendar" id="cal2"></i></span>
</div>

在1.2.0版本中,默认情况下:


您可以这样完成,但html中有一个小的变化

<input type="text" class="datepicker" id="tb_date">  
<label class="add-on" for="tb_date">
  <i class="icon-calendar" id="cal2"></i>
</label>


你错了,OP说的是bootstrap datepicker,而你的答案是jQuery datepicker。datepicker不会消失。它仍然是开放的。哪个datepicker?bootstrap datepicker有很多分支;你使用的是eternicode版本、eyecon版本还是其他版本?回答得很好!