Weekday jQuery UI Tabs open on current day

旧时模样 提交于 2019-12-02 01:31:59

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');

and needs the jQuery and jQuery UI libraries.

Demo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!