[英]Show/Hide two Divs with Jquery
i have two div's: 我有两个div:
<a href="#" class="component_expand"></a>
<div class="component_wrapper">
</div>
<a href="#" class="component_expand"></a>
<div class="component_wrapper">
</div>
Jquery code: Jquery代码:
<script type="text/javascript">
$(document).ready(function(){
$(".component_wrapper").hide();
$(".component_expand").show();
$('.component_expand').click(function(){
$(".component_wrapper").slideToggle();
});
});
</script>
I try every time I click on "component expand" one DIV open. 我每次点击“组件展开”时都会尝试打开一个DIV。 Now open two I'd be happy with who they help me on
现在打开两个,我很高兴他们帮助我
Use an instance of this
and .next
使用的一个实例,
this
和.next
$('.component_expand').click(function(){
$(this).next(".component_wrapper").slideToggle();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.