单击链接后停止表行切换 [英] Stop table row toggle upon clicking link

查看:71
本文介绍了单击链接后停止表行切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要做的是当有人点击表格行中的网址链接时停止切换。

What I am trying to do is to stop the toggling when someone clicks on a url link in the table row.

$(document).ready(function () {
    $("#report tr:odd").addClass("odd");
    $("#report tr:not(.odd)").hide();
    $("#report tr:first-child").show();

    $("#report tr.odd").click(function () {
        $(this).next("tr").toggle();
        $(this).find(".arrow").toggleClass("up");
    });
    //$("#report").jExpand();
});

网址链接位于同一个切换行,当有人点击网址链接时,也切换我试图阻止的行。有关如何执行此操作的任何指示?

The url link sits right on the same toggling row which in turn when someone clicks the url link, it also toggles the row which I am trying to stop. Any pointers on how to do this?

推荐答案

由于锚点在tr元素中,每当点击调用anchor ,该事件将传播到父 tr ,并且还会执行其click函数。

As the anchor is in tr element,whenever click on anchor is called ,the event will be propagated to the parent tr and its click function is also executed.

$('a').click(function(e){
    e.stopPropagation();
});

这会停止锚定点击事件冒泡到父母的事件

this stops the event of anchor click to bubble up to the parent

这篇关于单击链接后停止表行切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆