保留当前选项卡不起作用的脚本 - (标签未硬编码)

时间:2016-01-02 05:30:14

标签: javascript jquery html

下面是我的代码涉及标签的摘录(标签不是硬编码的)。问题是,我无法在刷新,更新等后保留当前选项卡。如果您需要整个脚本,请通知我。以下是有关标签的摘录。仅供参考,我对编程知识有限。 TQ

<html>    
    <head>        
        <link href="SpryAssets/SpryTabbedPanels.css" rel="stylesheet" type="text/css">
        <script src="SpryAssets/SpryTabbedPanels.js" type="text/javascript"></script>
        <script type="text/javascript">
            function MM_jumpMenu(targ, selObj, restore) { //v3.0
                eval(targ + ".location='" + selObj.options[selObj.selectedIndex].value + "'");
                if (restore) selObj.selectedIndex = 0;
            }
        </script>
    </head>

    <body>
        <div id="apDiv3">
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <div id="TabbedPanels1" class="TabbedPanels">
                <ul class="TabbedPanelsTabGroup" id="nav">
                    <li class="TabbedPanelsTab" tabindex="0">Tab 1</li>
                    <li class="TabbedPanelsTab" tabindex="0">Tab 2</li>
                </ul>
                <div class="TabbedPanelsContentGroup">
                    <div class="TabbedPanelsContent">
                        <p>

                        </p>

                        <script>
                            $('ul.tabs').each(function() {
                                // For each set of tabs, we want to keep track of
                                // which tab is active and its associated content
                                var $active, $content, $links = $(this).find('a');

                                // If the location.hash matches one of the links, use that as the active tab.
                                // If no match is found, use the first link as the initial active tab.
                                $active = $($links.filter('[href="' + location.hash + '"]')[0] || $links[0]);
                                $active.addClass('active');

                                $content = $($active[0].hash);

                                // Hide the remaining content
                                $links.not($active).each(function() {
                                    $(this.hash).hide();
                                });

                                // Bind the click event handler
                                $(this).on('click', 'a', function(e) {
                                    // Make the old tab inactive.
                                    $active.removeClass('active');
                                    $content.hide();

                                    // Update the variables with the new link and content
                                    $active = $(this);
                                    $content = $(this.hash);

                                    // Make the tab active.
                                    $active.addClass('active');
                                    $content.show();

                                    // Prevent the anchor's default click action
                                    e.preventDefault();
                                });
                            });
                        </script>

                        </p>
                    </div>
                    <div class="TabbedPanelsContent">
                        <form name="form2" action="useracc-test.php" method="post">
                            <p>&nbsp;</p>

                            <table width="500" border="0">
                                <tr>
                                    <td>category</td>
                                    <td>
                                        <select name="jumpMenu" id="jumpMenu" onChange="MM_jumpMenu('parent',this,0)">
                                            <option value="useracc-test.php">Category</option>
                                            <option value="useracc-test.php">Type1</option>
                                            <option value="useracc-test.php">Color</option>
                                            <option value="useracc-test2-jumpmenu.php">Type2</option>
                                            <option value="useracc-test2-jumpmenu.php">Hobby</option>
                                        </select>
                                    </td>
                                </tr>

0 个答案:

没有答案