jquery .siblings do not work
Posted
by Mango
on Stack Overflow
See other posts from Stack Overflow
or by Mango
Published on 2010-05-07T14:06:39Z
Indexed on
2010/05/07
14:08 UTC
Read the original article
Hit count: 132
jQuery
Hi i want when the one #box is open the others #box close.
Html:
<div id="main">
<div id="link">click</div><!--/*div*/-->
<div id="box">content1</div><!--/*div*/-->
</div><!--/*div*/-->
<div id="main">
<div id="link">click2</div><!--/*div*/-->
<div id="box">content2</div><!--/*div*/-->
</div><!--/*div*/-->
<div id="main">
<div id="link">click3</div><!--/*div*/-->
<div id="box">content3</div><!--/*div*/-->
</div><!--/*div*/-->
Jquery:
<script type="text/javascript">
$(document).ready(function(){
$('#main #box').css('display', 'none')
$('#main #link').click(function() {
$(this).next('#main #box').slideToggle('slow')
.siblings('#main #box:visible').css('display', 'none');
});
});
</script>
Thanks!
© Stack Overflow or respective owner