简体   繁体   English

如何在图标单击上不仅在输入单击上打开bootstrap-datepicker

[英]How do you open bootstrap-datepicker on icon click not only on input click

Is it possible to open datepicker on click input or span with calendar icon? 是否可以在单击输入时打开日期选择器或使用日历图标打开日期选择器?

http://www.eyecon.ro/bootstrap-datepicker http://www.eyecon.ro/bootstrap-datepicker

My code 我的密码

<div class="input-group datepicker">
<label>Date</label>
<input type="text" class="form-control" placeholder="YYYY-MM-DD" value="" name="date">
<span class="input-group-addon"><span class="glyphicon calendar"></span></span>
</div>


$(document).ready(function(){
    $('.datepicker').datepicker({'format': 'yyyy-mm-dd'});
});

Span holds calendar icon and on click I want to show calendar. Span拥有日历图标,然后单击“我要显示日历”。

Is this possible? 这可能吗? How to do it? 怎么做?

Do you have to use the component with the calendar icon? 您是否必须将组件与日历图标一起使用?

You could instead use the first or second component from here and add a background calendar image in input : 您可以改为从此处使用第一个或第二个组件,并在input中添加背景日历图像:

input {
background: url (path/to/your/calendar/image) no-repeat right center;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM