禁用单击链接功能并屏蔽表格行

时间:2010-11-15 16:02:07

标签: jquery css onclick html-table

我正在尝试实现一种功能,当点击链接时,相应的锚表行被有效地消隐,链接被禁用。

这可以使用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>

因此,如果单击锚点,该行将被消隐。

2 个答案:

答案 0 :(得分:0)

你可以尝试

.show() hide();

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

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

你想要什么。

答案 1 :(得分:0)

这段代码将自我解释:

$(".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
  [..]
});