最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - Redirecting to another page with jQuery UI tabs - Stack Overflow

matteradmin5PV0评论

I have jQuery UI tabs on my page, but I would like to use them as a navigation between the pages and not like showing and hiding divs as it was designed to. So basically I still want to use jQuery UI tabs but for global navigation and the correct highlighting.

Anyone could help me with this?

I can navigate already, but I'm still kinda stuck on highlighting the correct item in the following page. Any ideas how to achieve that?

$(document).ready(function() {
  var iSelectedTab = $('div#tabs ul a').filter('a[href="#"]');
  $("#tabs").tabs({
    selected: iSelectedTab,
    select: function (e, ui) {
      window.location.href=ui.tab.href;
    }
  });
});

But it isn't working. Any ideas?

I have jQuery UI tabs on my page, but I would like to use them as a navigation between the pages and not like showing and hiding divs as it was designed to. So basically I still want to use jQuery UI tabs but for global navigation and the correct highlighting.

Anyone could help me with this?

I can navigate already, but I'm still kinda stuck on highlighting the correct item in the following page. Any ideas how to achieve that?

$(document).ready(function() {
  var iSelectedTab = $('div#tabs ul a').filter('a[href="#"]');
  $("#tabs").tabs({
    selected: iSelectedTab,
    select: function (e, ui) {
      window.location.href=ui.tab.href;
    }
  });
});

But it isn't working. Any ideas?

Share Improve this question edited Nov 19, 2012 at 8:00 dda 6,2132 gold badges27 silver badges35 bronze badges asked Nov 19, 2012 at 7:51 AlnedruAlnedru 2,6559 gold badges53 silver badges92 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 3

I don't see the point of using the Tabs in this case...but to answer your question...

Say that we are in page1.html - for which you need tabs-0 to be active, your tabs structure should be like this (yes - it will not respect the standard structure of Jquery UI tabs):

<div id="tabs">
    <ul>
       <li><a href="#tabs-1">Page 1</a></li>
       <li><a href="page2.html#tabs-2">Page 2</a></li>
       <li><a href="page3.html#tabs-3">Page 3</a></li>
    </ul>
    <div id="tabs-1">This is page 1</div>
</div>

Note that there is no other tab containers in this page. page2.html would have the same structure as above

<div id="tabs">
    <ul>
       <li><a href="page1.html#tabs-1">Page 1</a></li>
       <li><a href="#tabs-2">Page 2</a></li>
       <li><a href="page3.html#tabs-3">Page 3</a></li>
    </ul>
    <div id="tabs-2">This is page 2</div>
</div>

At this point, you don't need any special JS code,

$("#tabs").tabs({
    select: function (e, ui) {
        window.location.href=ui.tab.href;
    }
});
Post a comment

comment list (0)

  1. No comments so far