工作日 jQuery UI 选项卡在当天打开
我有如下工作日 jQuery UI 选项卡,我想在当前工作日打开它们:
<div id="tabs">
<ul>
<li><a href="monday.php">Monday</a></li>
<li><a href="tuesday.php">Tuesday</a></li>
<li><a href="wednesday.php">Wednesday</a></li>
<li><a href="thursday.php">Thursday</a></li>
<li><a href="friday.php">Friday</a></li>
<li><a href="saturday.php">Saturday</a></li>
<li><a href="sunday.php">Sunday</a></li>
</ul>
<script type="text/javascript">
$(function() {
$( "#tabs" ).tabs({
ajaxOptions: {
error: function( xhr, status, index, anchor ) {
$( anchor.hash ).html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo." );
}
}
});
});
</script>
我希望选项卡在本周的当天打开,我知道这样的方法可以工作:
.eq((new Date().getDay() || 7) - 1).click();
但无法让它工作,希望得到一些帮助。另外,我希望当天的选项卡显示“今天”一词,而不是工作日。
我希望得到一些帮助。
谢谢,
布伦登
I have weekday jQuery UI tabs as follows which I want to open on the current weekday:
<div id="tabs">
<ul>
<li><a href="monday.php">Monday</a></li>
<li><a href="tuesday.php">Tuesday</a></li>
<li><a href="wednesday.php">Wednesday</a></li>
<li><a href="thursday.php">Thursday</a></li>
<li><a href="friday.php">Friday</a></li>
<li><a href="saturday.php">Saturday</a></li>
<li><a href="sunday.php">Sunday</a></li>
</ul>
<script type="text/javascript">
$(function() {
$( "#tabs" ).tabs({
ajaxOptions: {
error: function( xhr, status, index, anchor ) {
$( anchor.hash ).html(
"Couldn't load this tab. We'll try to fix this as soon as possible. " +
"If this wouldn't be a demo." );
}
}
});
});
</script>
I want the tabs to open on the current day of the week, I know something like this works:
.eq((new Date().getDay() || 7) - 1).click();
But can't get it to work and would appreciate some help. Also, I would like the tab for the current day to display the word 'Today' instead of the weekday.
I would appreciate some help.
Thanks,
Brendon
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用以下命令
选择
匹配的选项卡当前日期:您可以使用以下内容修改活动选项卡的文本:
HTML
JavaScript
,并且需要 jQuery 和 jQuery UI 库。
演示
You can use the following to
select
the tab matching the current day:and you could modify the text of the active tab with the following:
HTML
JavaScript
and needs the jQuery and jQuery UI libraries.
Demo