【问题标题】:Stop table row toggle upon clicking link单击链接时停止表行切换
【发布时间】:2014-01-09 01:32:14
【问题描述】:

我要做的是在有人点击表格行中的 url 链接时停止切换。

$(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();
});

url 链接位于同一切换行上,当有人单击 url 链接时,它也会切换我试图停止的行。有关如何执行此操作的任何指示?

【问题讨论】:

  • 你能把 html 贴出来
  • 请张贴 html,说明要切换的内容、想要切换的内容和不想切换的内容,单独的代码没有意义

标签: javascript jquery togglebutton


【解决方案1】:

我认为以下内容可能对您有用。虽然没有测试。

在您的链接中添加 Javascript 函数调用

$("#ANCHIOR_ID").click(function(event){
    event.stopPropagation();
    // then do your job there that you want to do in on click
  });

【讨论】:

    【解决方案2】:

    由于锚点在tr元素中,所以每当点击anchor时,该事件都会传播到父tr,并且它的点击函数也会被执行。

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

    这会阻止锚点点击事件冒泡到父级

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-18
      • 2019-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-31
      • 2011-08-24
      相关资源
      最近更新 更多