gpt4 book ai didi

javascript - HTML/JS - Bootstrap 日期选择器

转载 作者:行者123 更新时间:2023-11-27 23:57:53 25 4
gpt4 key购买 nike

过去,我构建的系统使用了 jQuery 日期选择器,而且效果很好。最近,我决定转而使用 Twitter Bootstrap 进行我的设计,并很快了解到它不喜欢 jQuery UI。

我正在尝试获取 http://www.eyecon.ro/bootstrap-datepicker/目前正在工作。

我查看了所有类似的问题及其解决方案,但似乎找不到任何直接适用于我的情况。

JavaScript:

<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link rel="icon" type="image/ico" href="../images/favicon.ico">
<script type="text/javascript" src="js/tinybox.js"></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="js/bootstrap-datepicker.js"></script>

<script>
$('#date').datepicker();
function delete(id)
{
var r=confirm("Are you sure you want to delete?")
if (r==true)
{
location.href = "delete.php?id=" + id;
}
}
function single(id)
{
TINY.box.show({iframe:'../view.php?id=' + id,boxid:'frameless',width:550,height:170,fixed:false,maskid:'bluemask',maskopacity:40,closejs:function(){closeJS()}})
}
</script>

html:

<input name="date" class="src_date" type="textarea" placeholder="DD-MM-YYYY" id="date" required>

我也试过 JS:

$(function() {
$("#date").datepicker({dateFormat: 'dd-mm-yyyy'});
});

最佳答案

此问题通常是 JS 冲突的结果,其中另一个插件导致 $ 变量行为异常。要解决这个问题,只需使用 jQuery 包装您的函数:

$('#date').datepicker();

=>

jQuery(function($){
$("#date").datepicker({format: 'dd-mm-yyyy'});
});

您的 dateFormat 参数也适用于 jQuery UI,对于 bootstrap datepicker,只需使用我在上面示例中使用的 format

关于javascript - HTML/JS - Bootstrap 日期选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22912405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com