【发布时间】:2018-07-10 02:57:15
【问题描述】:
我正在处理website,我想在点击日历图标时弹出日历。
我用来放置开始日期和结束日期的HTML代码是:
<div class="dates">
<div class="start_date">
<input class="form-control start_date mb-4" type="text" placeholder="start date">
<span class="fa fa-calendar start_date_calendar" aria-hidden="true "></span>
</div>
<div class="end_date">
<input class="form-control end_date mb-4" type="text" placeholder="end date">
<span class="fa fa-calendar end_date_calendar" aria-hidden="true "></span>
</div>
</div>
问题陈述:
我想知道我必须使用什么 js/jquery 代码才能在点击左侧和右侧的日历图标时弹出日历(在下面的屏幕截图中用箭头标记)。
我尝试放置以下代码,但不知何故我无法在点击日历图标时弹出日历。
<script>
$( function() {
$( "#datepicker" ).datepicker();
} );
</script>
【问题讨论】:
-
您可能想要使用正确的 id 并将 datetimepicker 插件绑定到它。看看这个:jsfiddle.net/go6ygh6q
-
@alfonzjanfrithz 小提琴在工作吗?
-
是的,从我这边完全没问题..
-
@user5447339 我建议您使用 Vignesh Raja 的解决方案。最好在输入字段上显示弹出窗口,而不是在日历图标上使用单击事件。这允许用户从日历中选择或输入日期。
-
我已经在我的domain 中推送了 Vignesh Raja 更改,但它似乎不起作用。我收到以下错误
Uncaught TypeError: $(...).datepicker is not a function at ferhan.ferohost.com/:231你能看看我的代码我在做什么错误吗?你可以在chrome浏览器中按CTRL+U查看我的源代码,我很确定你知道。
标签: javascript jquery html css datepicker