Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在没有父项和子项的其他选择器上设置可见_Javascript_Jquery_Html - Fatal编程技术网

Javascript 在没有父项和子项的其他选择器上设置可见

Javascript 在没有父项和子项的其他选择器上设置可见,javascript,jquery,html,Javascript,Jquery,Html,我可以使用children()和parent(),但如果输入不是children和parent呢 <table> <tr> <td> <input type="checkbox" class="check"> <select style="display: none"><option>1</option><option>2</option></select>

我可以使用children()和parent(),但如果输入不是children和parent呢

<table>
<tr>
<td>
    <input type="checkbox" class="check">
    <select style="display: none"><option>1</option><option>2</option></select>
    <select style="display: none"><option>1</option><option>2</option></select>
    <input type="text" style="display: none">
</td>
    </tr><tr>
    <td>
    <input type="checkbox" class="check">
    <select style="display: none"><option>1</option><option>2</option></select>
    <select style="display: none"><option>1</option><option>2</option></select>
    <input type="text" style="display: none">
</td></tr><tr>
    <td>
    <input type="checkbox" class="check">
    <select style="display: none"><option>1</option><option>2</option></select>
    <select style="display: none"><option>1</option><option>2</option></select>
    <input type="text" style="display: none">
</td></tr><tr>
    <td>
    <input type="checkbox" class="check">
    <select style="display: none"><option>1</option><option>2</option></select>
    <select style="display: none"><option>1</option><option>2</option></select>
    <input type="text" style="display: none">
</td>
</tr>
</table>

12
12
12
12
12
12
12
12
如果我用类check选中复选框,那么2 select和input应该是可见的。我如何使用jQuery进行查询


小提琴:

根据您的情况,您可以使用几个不同的选择器来查找兄弟姐妹。在这种情况下,您可以使用
兄弟姐妹()

您可以使用来选择它的所有同级(同一父级下同一级别的元素)

$('.check').click(function(){    
    $(this).siblings("select, input").toggle() 
})
$('.check').click(function(){
    $(this).siblings().toggle();
})​