我有工作日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();
但无法让它发挥作用,并希望得到一些帮助。此外,我希望当天的标签显示“今天”而不是工作日。
我将不胜感激。
谢谢,
布伦登
答案 0 :(得分:3)
您可以使用以下select
与当天匹配的标签:
$('#tabs').tabs('select', ((new Date().getDay() || 7) - 1));
您可以使用以下内容修改活动标签的文本:
$('#tabs .ui-state-active a').text('Today');
<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>
</div>
$('#tabs').tabs();
$('#tabs').tabs('select', ((new Date().getDay() || 7) - 1));
$('#tabs .ui-state-active a').text('Today');
并且需要jQuery和jQuery UI库。