作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在单击超链接(在隐藏的 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" );
});
});
关于javascript - 单击超链接切换另一个 div 的类的 jquery 事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28493459/
我是一名优秀的程序员,十分优秀!