gpt4 book ai didi

jquery - jquery 中的隐藏()

转载 作者:行者123 更新时间:2023-12-01 06:31:59 25 4
gpt4 key购买 nike

在 jquery 代码中,我动态显示和隐藏一些内容。

            if (this.hide()) {

this.show();
}
else {
alert("Hello");
this.hide();

}

但是其他部分永远不会被执行。为什么?

最佳答案

我会做这样的事情:

if($(this).is(':hidden')) { 
$(this).show();
}
else {
$(this).hide();
}

或者根据您想要执行的操作,您可以尝试 toggle()

关于jquery - jquery 中的隐藏(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1782768/

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