gpt4 book ai didi

javascript - JQuery Datepicker 不适用于 IE 7

转载 作者:行者123 更新时间:2023-11-28 07:29:12 25 4
gpt4 key购买 nike

我正在使用 Jquery Datetimepicker。日期时间选择器的详细信息可以在以下位置找到: DateTimePicker Details

此日期选择器设置为显示在“单击”上并链接到输入框。Asp代码如下:

<link type="text/css" href="css/jquery.datetimepicker.css" rel="stylesheet" />  
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script>
<script src="js/jquery.datetimepicker.js" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function () {

/*DatePicker initializations*/
var DATEPICKER_FORMAT = 'm/d/Y';
var DATETIMEPICKER_FORMAT = 'm-d-Y H:i:s';
var TIMEPICKER_FORMAT = 'g:ia';
$(function () {
$(".datepickerwithicon").datetimepicker({
format: DATEPICKER_FORMAT,
datepicker: true,
timepicker: false,
step: 1,
allowBlank: true,
closeOnDateSelect: true,
validateOnBlur: false
});

$(".datetimepickerwithicon").datetimepicker({
format: DATETIMEPICKER_FORMAT,
datepicker: true,
timepicker: true,
step: 5,
allowBlank: true,
closeOnDateSelect: true,
validateOnBlur: false
});

/* Append calendar icon image. */
$('.datepickerwithicon, .datetimepickerwithicon').each(function () {
var dateInput = $(this);
var newImgId = dateInput.attr('id') + '_icon';
$("<img/>", {
"src": "Images/calendar-icon.png",
"class": "ui-datepicker-trigger",
"id": newImgId
}).insertAfter(dateInput);

$('#' + newImgId).on('click', function () {
dateInput.datetimepicker('show');
});
dateInput.click(function (event) {
$('.xdsoft_datepicker.active .xdsoft_calendar').focus();
});
});


});

});

</script>

</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td>
<asp:Label ID="lbStart" runat="server" Text="Start :" ForeColor="Black"></asp:Label>&nbsp;
<input type="text" id="StartDate" name="StartDate" runat="server" class="datetimepickerwithicon" />&nbsp;
</td>
<td>`
<asp:Label ID="lbEnd" runat="server" Text="End :" ForeColor="Black"></asp:Label>&nbsp;
<input type="text" id="EndDate" name="EndDate" runat="server" class="datetimepickerwithicon"/>&nbsp;
</td>
</tr>
</table>
</form>
</body>

问题:日期时间选择器不会出现在 IE 7 上的点击事件上。但是,它在所有其他版本的 IE、Chrome 和 Firefox 上运行良好。

关于如何使其在 IE 7 上运行有什么想法吗?

最佳答案

抱歉回复晚了,但我在这里尝试了同样的操作,唯一更改的是 CSS 和 JS 文件的路径。这对我来说效果很好。您能向我提供您在 IE 中收到的错误消息吗?我可以解决这个问题并快速为您提供解决方案。 :)

更新2:您好,这是我用于测试的代码。我已经从您在问题中提供的源下载了该插件,并将其作为 HTML 文件运行。您能做同样的事情并让我知道它在您的浏览器中是否有效吗?如果我在这件事上占用了您很多时间,真的很抱歉。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link type="text/css" href="css/jquery.datetimepicker.css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.17.custom.min.js"></script>
<script src="js/jquery.datetimepicker.js" type="text/javascript"></script>
<script type="text/javascript">

$(document).ready(function () {

/*DatePicker initializations*/
var DATEPICKER_FORMAT = 'm/d/Y';
var DATETIMEPICKER_FORMAT = 'm-d-Y H:i:s';
var TIMEPICKER_FORMAT = 'g:ia';
$(function () {
$(".datepickerwithicon").datetimepicker({
format: DATEPICKER_FORMAT,
datepicker: true,
timepicker: false,
step: 1,
allowBlank: true,
closeOnDateSelect: true,
validateOnBlur: false
});

$(".datetimepickerwithicon").datetimepicker({
format: DATETIMEPICKER_FORMAT,
datepicker: true,
timepicker: true,
step: 5,
allowBlank: true,
closeOnDateSelect: true,
validateOnBlur: false
});

/* Append calendar icon image. */
$('.datepickerwithicon, .datetimepickerwithicon').each(function () {
var dateInput = $(this);
var newImgId = dateInput.attr('id') + '_icon';
$("<img/>", {
"src": "Images/calendar-icon.png",
"class": "ui-datepicker-trigger",
"id": newImgId
}).insertAfter(dateInput);

$('#' + newImgId).on('click', function () {
dateInput.datetimepicker('show');
});
dateInput.click(function (event) {
$('.xdsoft_datepicker.active .xdsoft_calendar').focus();
});
});


});

});

</script>

</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td>
<asp:Label ID="lbStart" runat="server" Text="Start :" ForeColor="Black"></asp:Label>&nbsp;
<input type="text" id="StartDate" name="StartDate" runat="server" class="datetimepickerwithicon" />&nbsp;
</td>
<td>`
<asp:Label ID="lbEnd" runat="server" Text="End :" ForeColor="Black"></asp:Label>&nbsp;
<input type="text" id="EndDate" name="EndDate" runat="server" class="datetimepickerwithicon"/>&nbsp;
</td>
</tr>
</table>
</form>
</body>
</html>

关于javascript - JQuery Datepicker 不适用于 IE 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29294546/

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