CSS 显示:无 & JS .show() 破坏 JQuery 和 AjaxToolkit 日期选择器
因此,我使用 java 脚本、jQuery 和 CSS 创建了一个选项卡式界面,其中我只需在包含选项卡内容的 div 上调用 .show() 和 .hide() 即可。所有这些都工作得很好;但是,其中一个选项卡需要用户使用日期选择器(我已使用 jQuery 和 AjaxToolkit DatePickers 尝试过此操作)。
日期选择器附加到第三个选项卡上的输入,并且将在我第一次进入第三个选项卡时按下该框(如预期)时显示;但是,随后显示第三个选项卡时,单击日期选择器输入根本不起作用。
控制选项卡的 java 脚本如下:
$(document).ready(function () {
// initialize the first tab as selected
$('#tabMenu > li:eq(0)').css('backgroundColor', '#E9E6D7')
$('#tabMenu > li:eq(0)').addClass('selected');
// hide all of the tabs but the first
$('.tabBoxBody div').hide();
$('.tabBoxBody div:eq(0)').show();
// whenever a list item in the tab bar is clicked
$('#tabMenu > li').click(function () {
// make sure the tab isn't already selected
if (!$(this).hasClass('selected')) {
// remove selected from the old tab and add it to the new
$('#tabMenu > li').removeClass('selected');
$(this).addClass('selected');
// hide the old tab's contents and show the new one's
$('.tabBoxBody div').hide();
$('.tabBoxBody div:eq(' + $('#tabMenu > li').index(this) + ')').show()
// clear all background colors and set the new tab's color
$('#tabMenu > li').css('backgroundColor', '#C2CBDA')
$(this).css('backgroundColor', '#E9E6D7')
}
})
任何帮助或深入了解为什么会出现这种情况将不胜感激。
谢谢, 克里斯
So, I created a tabbed interface using java script, jQuery, and CSS in which I simply call .show() and .hide() on div's that contain a tab's contents. All of which works perfectly fine; however, one of the tabs requires the user of a Date Picker (I've tried this using both a jQuery and the AjaxToolkit DatePickers).
The date picker is attached to an input on the third tab, and will show when the box is pressed (as is expected) the first time I go to the third tab; however, subsequent times in which the third tab is shown, clicking on the date picker input simply has no effect.
The java script that controls the tabs is below:
$(document).ready(function () {
// initialize the first tab as selected
$('#tabMenu > li:eq(0)').css('backgroundColor', '#E9E6D7')
$('#tabMenu > li:eq(0)').addClass('selected');
// hide all of the tabs but the first
$('.tabBoxBody div').hide();
$('.tabBoxBody div:eq(0)').show();
// whenever a list item in the tab bar is clicked
$('#tabMenu > li').click(function () {
// make sure the tab isn't already selected
if (!$(this).hasClass('selected')) {
// remove selected from the old tab and add it to the new
$('#tabMenu > li').removeClass('selected');
$(this).addClass('selected');
// hide the old tab's contents and show the new one's
$('.tabBoxBody div').hide();
$('.tabBoxBody div:eq(' + $('#tabMenu > li').index(this) + ')').show()
// clear all background colors and set the new tab's color
$('#tabMenu > li').css('backgroundColor', '#C2CBDA')
$(this).css('backgroundColor', '#E9E6D7')
}
})
Any help or insight into why this is the case would be greatly appreciated.
Thanks,
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为这一行会影响形成日期选择器的 div。
您可以向您的 div 添加一个类“选项卡”,然后就可以了
I think this line affects the divs that form the datepicker.
You could add a class 'tab' to your div and then just
每次在选项卡中加载内容时,您可以尝试将日期插件重新绑定到输入框。
You could try to rebind the date plugin to your input box each time you load the content in your tab.