使用 jQuery 在内容之间切换
我在这方面需要一些帮助:
我必须做这样的事情,而我的 jQuery 知识还不够:(
<div id="dog-button"></div>
<div id="cat-button"></div>
<div id="dog"></div>
<div id="cat"></div>
我们有两个按钮。当您单击狗按钮时,当您单击cat-button,cat-div 出现(在确切的位置,但我想这只是 CSS)。重要的是,该网站加载了狗并且不显示任何内容:-( 你有什么想法吗?
I need some help on this one:
I have to do something like this and my jQuery-knowledge just isn't enough :(
<div id="dog-button"></div>
<div id="cat-button"></div>
<div id="dog"></div>
<div id="cat"></div>
We have two buttons. When you click the dog-button, the dog-div should appear when you click the cat-button, the cat-div appears (on the exact spot but I guess this is just CSS). Its important, that the site loads with the dog and doesn't show just nothing. Do you have any ideas? :-(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
演示: http://jsfiddle.net/uhcHV/
Demo: http://jsfiddle.net/uhcHV/
这是一段适合您的代码,但是要扩展,您将需要进行少量编码(您需要添加到 $('#dog, #cat').hide(); 行 all要隐藏的额外 div):
http://jsfiddle.net/KRPZS/
Here is a jsfiddle of code that will work for you, however to scale you will need to do a small amount of coding (you will need to add to the $('#dog, #cat').hide(); line all the extra divs to hide):
http://jsfiddle.net/KRPZS/
HTML:
JavaScript:
HTML:
Javascript:
您可以尝试以下方法:
HTML:
Javascript:
You could try something along these lines:
HTML:
Javascript:
这是您正在寻找的内容:
HTML
CSS
JAVASCRIPT
查看此 jsFiddle: http://jsfiddle.net/KVvQV/希望
这有帮助。
鲍勃
Here is something like what you are looking for:
HTML
CSS
JAVASCRIPT
Check out this jsFiddle: http://jsfiddle.net/KVvQV/
Hope this helps.
Bob