[英]jquery select div below parent div
I have a few divs set up like so: 我有几个div设置如下:
<div class="menu_options">
<div class="parent_div">input field</div>
<div class="children_div">
<div class='something">field</div>
<div class="something_else">field</div>
</div>
</div>
<div class="menu_options">
<div class="parent_div">input field</div>
<div class="children_div">
<div class='something">field</div>
<div class="something_else">field</div>
</div>
</div>
<div class="menu_options">
<div class="parent_div">input field</div>
<div class="children_div">
<div class='something">field</div>
<div class="something_else">field</div>
</div>
</div>
in jquery i am doing 在jquery我正在做
$('.parent_options').each(function() {
$(this).click(function() {
});
});
right now $(this) is giving me the parent_div that i clicked on and I need to be able to move down to the children_div and hide the entire children_div. 现在$(这个)给了我点击的parent_div,我需要能够向下移动到children_div并隐藏整个children_div。 Any ideas. 有任何想法吗。 I know in prototype i used a down function but not sure if jquery has it. 我知道在原型中我使用了down函数但不确定jquery是否有它。
$('.parent_div').each(function() {
$(this).click(function() {
$(this).next().hide();
});
});
If you're binding the function to all .menu-options
, there's no need for each()
. 如果您将函数绑定到所有.menu-options
,则不需要each()
。 This should work if I understood your query properly: 如果我正确理解您的查询,这应该有效:
$('.parent_div').click(function() {
$(this).siblings('.children_div').hide();
});
try .next()
试试.next()
$( this ).next( ".tb-contents'" ).show();
This will work. 这会奏效。
Thanks 谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.