本文介绍了工作日jQuery UI选项卡在当日打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我有以下要在当前工作日打开的工作日jQuery UI选项卡:

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.

我将不胜感激.

谢谢

布伦登

推荐答案

您可以使用以下内容 select 与当天匹配的标签:

You can use the following to select the tab matching the current day:

$('#tabs').tabs('select', ((new Date().getDay() || 7) - 1));

,您可以使用以下内容修改活动标签的文本:

and you could modify the text of the active tab with the following:

$('#tabs .ui-state-active a').text('Today');

HTML

<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>

JavaScript

$('#tabs').tabs();
$('#tabs').tabs('select', ((new Date().getDay() || 7) - 1));
$('#tabs .ui-state-active a').text('Today');

,并且需要jQuery和jQuery UI库.

and needs the jQuery and jQuery UI libraries.

演示

这篇关于工作日jQuery UI选项卡在当日打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 20:18