gpt4 book ai didi

javascript - 显示和隐藏 div : SVG Into a html with several layers

转载 作者:行者123 更新时间:2023-11-30 10:04:38 26 4
gpt4 key购买 nike

我制作了一个 Svg,现在我正在变成一个 HTML。我正在使用 Jquery 来显示和隐藏 div。我有大约 200 个 div。我使用的是按钮,因此,当我单击一个 div 时,我必须显示特定的 div,但我需要隐藏所有其他的 div。我觉得不是大神在这里一一列举。我可以显示特定的 div 并隐藏所有其他的吗??

我正在使用这个:

$(document).ready(function(){
$("#div1,#div3,#div2").click(function(){
$('#div4,#div5,#div6,#div7').show(1000);
// I need to hide all other divs, the 193 left...
$('').hide(1000);
});
});

最佳答案

给你需要一次隐藏所有的 div 一个“类”而不是一个“id”。

https://css-tricks.com/the-difference-between-id-and-class/

$(document).ready(function(){
$("#div1,#div3,#div2").click(function(){
$('#div4,#div5,#div6,#div7').show(1000);
// I need to hide all other divs, the 193 left...
$('.generalClassName').hide(1000);
});
});

关于javascript - 显示和隐藏 div : SVG Into a html with several layers,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29833384/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com