bom*_*bai 2 javascript jquery class function
我有这个代码.
CSS
body {
font-family:Verdana, Geneva, sans-serif;
font-size:14px;
}
.slidingDiv {
height:300px;
background-color: #99CCFF;
padding:20px;
margin-top:10px;
border-bottom:5px solid #3399FF;
}
.show_hide {
display:none;
}
Run Code Online (Sandbox Code Playgroud)
HTML
<a href="#" class="show_hide">Show/hide</a>
<br />
<div class="slidingDiv">
Fill this space with really interesting content.
<a href="#" class="show_hide">hide</a>
</div>
Run Code Online (Sandbox Code Playgroud)
JS
$(document).ready(function(){
$(".slidingDiv").hide();
$(".show_hide").show();
$('.show_hide').click(function(){
$(".slidingDiv").slideToggle();
});
});
Run Code Online (Sandbox Code Playgroud)
有人告诉我是否有可能添加这个jquery函数,如果我点击它,同时显示/隐藏一个新的div,将类更改为标记并从另一个标记中删除另一个类?我该怎么做?
谢谢.
是的,你可以看看方法addClass和removeClass.
| 归档时间: |
|
| 查看次数: |
6191 次 |
| 最近记录: |