开发者

Good jQuery Content Switcher [closed]

开发者 https://www.devze.com 2022-12-27 21:20 出处:网络
Closed. This question needs to be more focused. It is not currently accepting answers. 开发者_Python百科Want to improve this question? Update the question so it focuses on one problem only
Closed. This question needs to be more focused. It is not currently accepting answers.
开发者_Python百科

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 2 years ago.

Improve this question

Does anyone know of a good jQuery content switcher? I want to switch a log in and register form.


You can do something like this with minimal code, for example if you had:

<div class="links">
  <a href="#login">Login</a>
  <a href="#register">Register</a>
</div>

<div id="login" class="panels">
  Login Stuff
</div>
<div id="register" class="panels">
  Registration Stuff
</div>

You could do jQuery like this:

$(".links a").click(function() {
  $(".panels").hide();
  $(this.hash).fadeIn();
});

Just hide both initially with CSS if you wanted, like this:

.panels { display: none; }

When you clicked either link above, it would hide the other panels, and fade in the one you wanted to switch to for a nice effect...use the same convention as above and you could add any number of panels and links.

Some other pre-built alternatives if you want more complicated content arrangement would be something like:

  • jQuery UI Tabs
  • jQuery UI Accordion
0

精彩评论

暂无评论...
验证码 换一张
取 消