Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.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 排除.not中的多个元素,包括$this_Jquery_Html - Fatal编程技术网

Jquery 排除.not中的多个元素,包括$this

Jquery 排除.not中的多个元素,包括$this,jquery,html,Jquery,Html,下面隐藏了所有表格行,不包括带有class.accordion或课程标题的行 $('#course_list').find("tr").not('.accordion, .course_header').hide(); 如何排除$(this.next(“tr”)表行?这是假设此是刚刚单击的tr 详细信息 我正在用手风琴制作一张桌子。在解决方案不变的情况下,如果单击一行,其子行将保持展开状态。请注意,当您单击一行时,它会正确展开子行,但我希望在再次单击同一行时它会关闭子行 我目前拥有的: v

下面隐藏了所有表格行,不包括带有class
.accordion
课程标题的行

  $('#course_list').find("tr").not('.accordion, .course_header').hide();
如何排除
$(this.next(“tr”)
表行?这是假设
是刚刚单击的
tr

详细信息

我正在用手风琴制作一张桌子。在解决方案不变的情况下,如果单击一行,其子行将保持展开状态。请注意,当您单击一行时,它会正确展开子行,但我希望在再次单击同一行时它会关闭子行

我目前拥有的:

var $course_list = $('#course_list');
$course_list.find("tr").not('.accordion, .course_header').hide();
$course_list.find("tr").eq(0).show();

$course_list.find(".accordion").click(function(){
   $course_list.find("tr").not('.accordion, .course_header').hide();
   $(this).next("tr").fadeToggle('fast');
});
以下是表格布局:

<table id="course_list">
  <thead>
    <tr class="course_header">
      <th>Date</th>
      <th>Presenter</th>
      <th>Title</th>
     </tr>
  </thead>
  <tbody>
    <tr class="accordion">
      <td>09.26.14</td>
      <td>Arthur Dent</td>
      <td>Example Course</td>
    </tr>
    <tr>
      <td colspan="4">
        COURSE DETAILS GO HERE
      </td>
    </tr>

    <tr class="accordion">
      <td>09.30.14</td>
      <td>Winston Smith</td>
      <td>Another Example</td>
    </tr>
    <tr>
      <td colspan="4">
        COURSE DETAILS GO HERE
      </td>
    </tr>
  </tbody>
</table>

日期
节目主持人
标题
09.26.14
阿瑟·邓特
范例课程
课程详情请点击此处
09.30.14
温斯顿·史密斯
另一个例子
课程详情请点击此处

您是否尝试将其附加到链中:

var next = $(this).next("tr");
$course_list.find("tr").not('.accordion, .course_header').not(next).hide();

你的解决方案似乎符合我的要求,但现在我才意识到我问错了问题:)。实际上,我想忽略
$(this).next(“tr”)
。事实证明,您的解决方案也适用于该特定问题:
。而不是($(this).next(“tr”)
。你能用这个更新你的答案吗?我会接受的?你肯定让我走上了正确的道路。是的,我刚刚提出了上面的解决方案:)