Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.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
Jquery 隐藏所有类<;表>;除了我单击的那个和最近的父div_Jquery - Fatal编程技术网

Jquery 隐藏所有类<;表>;除了我单击的那个和最近的父div

Jquery 隐藏所有类<;表>;除了我单击的那个和最近的父div,jquery,Jquery,我有一个问题,我需要能够用类隐藏所有其他表(单击)。此表,此外还隐藏最近的父div。引导表。到目前为止,我可以隐藏所有其他表,但父div仍然存在。我尝试了几种添加.resest('.bootstrap table')的变体,但无法使其工作 HTML <a class="report" data-id="table-javascript-1">link1</a> <a class="report" data-id="table-javascript-2">lin

我有一个问题,我需要能够用类
隐藏所有其他表(单击)。此表
,此外还隐藏最近的父div
。引导表
。到目前为止,我可以隐藏所有其他表,但父div仍然存在。我尝试了几种添加
.resest('.bootstrap table')
的变体,但无法使其工作

HTML

<a class="report" data-id="table-javascript-1">link1</a>
<a class="report" data-id="table-javascript-2">link2</a>
<a class="report" data-id="table-javascript-3">link3</a>

<div class="bootstrap-table">
    <table class="this_table" id="table-javascript-1"></table>
</div>
<div class="bootstrap-table">
    <table class="this_table" id="table-javascript-2"></table>
</div>
<div class="bootstrap-table">
    <table class="this_table" id="table-javascript-3"></table>
</div>
  • 需要添加一行显示所有表,然后隐藏()
  • $(document).on('click','report',function(){
    $('.bootstrap table').show()//添加此项以在隐藏之前显示所有表
    $('.this_table')。不是('.'+$(this.attr('data-id'))。最近('.bootstrap table')。隐藏();
    });
    
    
    链接1
    链接2
    链接3
    1.
    2.
    3.
    
  • 需要添加一行显示所有表,然后隐藏()
  • $(document).on('click','report',function(){
    $('.bootstrap table').show()//添加此项以在隐藏之前显示所有表
    $('.this_table')。不是('.'+$(this.attr('data-id'))。最近('.bootstrap table')。隐藏();
    });
    
    
    链接1
    链接2
    链接3
    1.
    2.
    3.
    
    在这里,我隐藏了所有包含类引导表的元素,然后从这个中,我找到了id并显示了最近的引导表

    在这里,我隐藏了所有包含类引导表的元素,然后从这个中,我找到了id并显示了最近的引导表

    $(document).on('click', '.report', function() {
        $('.this_table').not('#'+$(this).attr('data-id')).closest('.bootstrap-table').hide();
    });
    
    $(document).on('click', '.report', function() {
     $('.bootstrap-table').hide(); 
    var tableToShow=$(this).attr('data-id');
    $('#'+tableToShow).closest('.bootstrap-table').show(); 
    });