【问题标题】:Disable click link functionality and mask out a table row禁用点击链接功能并屏蔽表格行
【发布时间】:2017-06-14 23:47:32
【问题描述】:

我正在尝试实现功能,当单击链接时,相应的锚表行会被有效地清空并禁用链接。

这可以使用 jQuery 吗?

其中一个表格行的示例是:-

<tr class="bcell">
    <th scope="row"><a title="bla" class="addlink" id="a_205">Adrian&nbsp;Apple</a></th>
    <td>name</td>
    <td class="bcell">
        <span>0&nbsp;/&nbsp;0</span>
    </td>
    <td>jt 76 99 44 D</td>
    <td>12122121212121</td>
</tr>

因此,如果单击锚点,则该行将被空白。

【问题讨论】:

    标签: jquery css onclick html-table


    【解决方案1】:

    这个 sn-p 将不言自明:

    $(".addlink").click(function(){
      [..]
    
      //$(this) refers to the clicked anchor
      //With .parents("tr:first") you retrieve
      //the desired anchor row
      var AnchorRow = $(this).parents("tr:first");
    
      // Now you can do wathever you want: You have the anchor row (It's a JQuery Object)
      // And the anchor link
      [..]
    });
    

    【讨论】:

      【解决方案2】:

      你可以试试

      .show() hide();
      

      使用.html() or .text()替换内容本身

      addClass and removeClass or add() 用于添加 css。

      随心所欲。

      【讨论】:

      • 想我将使用下面的想法从链接和表格行中添加/删除类。
      猜你喜欢
      • 2016-08-03
      • 2020-02-17
      • 2020-11-03
      • 2011-09-23
      • 1970-01-01
      • 2016-11-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多