单击tr.时排除链接



下面是页面:http://nm-bootstrap.gydev.com/course-delivery.php

标题行上的V形切换图标和书签图标都是在第一个th之前准备的。如果单击带有th的tr,我有一些js可以切换下面的行。

问题是,我需要从事件中排除该书签(一个类为"bookmark this"的<a>),因为需要有人能够在不切换下面行的情况下为整个部分添加书签。因此,除了书签之外的整行都应该触发该事件。

这是jQuery使其工作

$("#table-modules tbody tr:not(.section-title)").hide();
$("#table-modules tbody tr.section-title").click(function(){
    $(this).nextUntil('tr.section-title').toggle().end()
        .find('.icon-chevron-right').toggle().end()
        .find('.icon-chevron-down').toggle();
});
$(".bookmark-this").click(function(){
    $(this).find('.icon-bookmark-empty').toggle().end()
        .find('.icon-bookmark').toggle();
});

这是渲染的html 的前2行

<tr class="section-title" style="cursor: pointer; ">
<th><i class="icon-chevron-right grayLight"></i><i class="icon-chevron-down grayLight" style="display: none; "></i><a class="bookmark-this"><i class="icon-bookmark-empty grayLight"></i><i class="icon-bookmark red" style="display: none; "></i></a>1. Introduction</th>
<th>&nbsp;</th>
<th>11:53</th>
</tr>
<tr style="display: none; ">
<td style="padding-left: 45px; "><a class="bookmark-this"><i class="icon-bookmark-empty grayLight"></i><i class="icon-bookmark red" style="display: none; "></i></a><a href="#">How to take an online course</a></td>
<td><img src="/img/icons/check-sm.png" width="16" height="13" alt="yes"></td>
<td>6:32</td>
</tr>

我该怎么做?

尝试将stopPropagation添加到.bookmark-this 的点击处理程序中

$(".bookmark-this").click(function(e){ e.stopPropagation() });

您可以使用非选择器

$("#table-modules tbody tr.section-title:not(.bookmark-this)").click

最新更新