Bootstrap 单击时打开日期选取器

jmo0nnb3  于 2023-03-06  发布在  Bootstrap
关注(0)|答案(2)|浏览(210)

我的搜寻表格如下。

<div class="search-bar-wrapper container-fluid">
        <div class="row">
            <div class="col-md-2"></div>
            <div class="col-md-8 search-bar">
                <span class="col-md-5 mag-name-field" contenteditable>
                </span>
                <span class="col-md-5 date-field datepicker fa fa-calendar open-datetimepicker" contenteditable>
                </span>
                <span class="col-md-2 btn-front">SEARCH</span>
            </div>
            <div class="col-md-2"></div>
        </div>
</div>

我想在单击“open-datetimepicker”时打开一个日期选取器,可以是引导日期选取器或jQuery日期选取器。

我在SO上试了几个答案。都没有结果。有人知道怎么做吗?

ycl3bljg

ycl3bljg1#

使用jquery试试下面的代码:

<span class="col-md-5 date-field datepicker fa fa-calendar open-datetimepicker" contenteditable
     onclick="$('#yourDatepickerName').datepicker('show');">
</span>
khbbv19g

khbbv19g2#

尝试使用输入字段。确保包含所有库并添加jQuery。祝你好运!

<link rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>
<div class="search-bar-wrapper container-fluid">
        <div class="row">
            <div class="col-md-2"></div>
            <div class="col-md-8 search-bar">
                <span class="col-md-5 mag-name-field" contenteditable>
                </span>
                <input id="date" class="col-md-5 date-field datepicker fa fa-calendar open-datetimepicker" contenteditable/>
                <span class="col-md-2 btn-front">SEARCH</span>
            </div>
            <div class="col-md-2"></div>
        </div>
</div>
<script>
$( "#date" ).datepicker();
</script>

相关问题