在另一个 div 内切换 div
我在同一页面上有多个切换 div,并且我要切换的 div 必须显示在同一个 div 中。
我在一个名为“box”的 div 中,有六个名为“1”、“2”、“3”、“4”等的 div,它们都是隐藏的。如果我单击名为“1”的 a
标记,它将在“box”div 中显示 div 1 的内容。如果我点击名为“2”的标签 a
,div 2 的内容将显示在“box”中并隐藏 div 1,依此类推。
我的问题是,如果 div 2 显示,我无法隐藏 div 1
这是我的代码:
$(document).ready(function () {
$('#content1').hide();
$('#content').hide();
var Prutswonder;
$('a.aici').click(function () {
$('#content1').toggle('slow');
});
$('a.acolo').click(function () {
$('#content').toggle('slow');
});
$("#" + Prutswonder).show("slow");
$(".toggle").not("#" + Prutswonder).hide("slow");
});
我需要一个 if 函数来隐藏除显示的 div 之外的所有内容。
I have multiple toggle divs on the same page, and the div I'm toggling must be displayed in the same div.
I have, in a div called 'box', six divs named '1', '2', '3', '4', etc., and they are all hidden. If I click on an a
tag named '1' it will display the contents of div 1 in 'box', div. If I click tag a
named '2', the contents of div 2 will display in 'box' and hide div 1, and so on.
My problem is that I haven`t been able to hide div 1 if div 2 is showing
This is my code:
$(document).ready(function () {
$('#content1').hide();
$('#content').hide();
var Prutswonder;
$('a.aici').click(function () {
$('#content1').toggle('slow');
});
$('a.acolo').click(function () {
$('#content').toggle('slow');
});
$("#" + Prutswonder).show("slow");
$(".toggle").not("#" + Prutswonder).hide("slow");
});
I need an if function to hide all except the div that is showing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以隐藏所有 div,然后显示您想要的......
You can hide all divs and then show the one you want...