gpt4 book ai didi

javascript - 单击超链接切换另一个 div 的类的 jquery 事件

转载 作者:行者123 更新时间:2023-11-28 08:26:53 25 4
gpt4 key购买 nike

我想在单击超链接(在隐藏的 div 上有一个 anchor )时显示一个隐藏的 div。我的研究使我相信使用 .switchClass 是可行的方法,但对于我来说,我一直无法让它发挥作用。这是我得到的:

HTML

<!-- link -->
<div id="rightnest">
<p>
You likely have a few questions, and maybe some of them can
<br>be answered
<a href="#questions" class="smoothScroll">
<ins>here</ins>
</a>.
</p>
</div>

<!-- hidden div that should gain .centernest on click -->
<div class="hide">
<p> a lot of text</p>
</div>

CSS

.hide {
height: 400px;
left: 200px;
padding-top: 10px;
position: absolute;
top: 5px;
vertical-align: top;
visibility: hidden;
width: 700px;
}
.centernest {
height: 400px;
left: 200px;
padding-top: 10px;
position: absolute;
top: 5px;
vertical-align: top;
visibility: visible;
width: 700px;
}

还有 .hide p、.hide h1、hide p a:link – 都具有 visibility:hidden; (与 .centernest 类相同)

JavaScipt

$(function() {
$("<ins>here</ins>").click(function(){
$(".hide").switchClass("hide", "centernest", 100);
return false;
});
});

最佳答案

试试这个:-

$(function() {
$(".smoothScroll").click(function(){
$(".hide").css( "visibility", "visible" );
});
});

Fiddle

关于javascript - 单击超链接切换另一个 div 的类的 jquery 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28493459/

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