简体   繁体   English

在可点击框内创建可点击链接(在内的ActionLink <a href>)</a>

[英]Make clickable link inside clickable box (ActionLink inside <a href>)

I am trying to make a whole table row clickable and have done so using javascript. 我正在尝试使整个表格行都可点击,并且已经使用javascript做到了。 However, this does not let you see the target link in the status bar and also prevents you from opening these links in new tabs. 但是,这不能让您在状态栏中看到目标链接,也无法在新选项卡中打开这些链接。

Therefore, I have been trying the following: 因此,我一直在尝试以下方法:

<tr>
  <td><a href="#">@Html.ActionLink(...)</a></td>
  <td><a href="#">@Html.ActionLink(...)</a></td>
  <td><a href="#">@Html.ActionLink(...)</a></td>
</tr>

Then using display:block; 然后使用display:block; on the anchors to make the full row clickable. 在锚点上以使整行都可点击

tr:hover { 
   background: red; 
}

td a { 
   display: block; 
   border: 1px solid black;
   padding: 16px; 
}

However, I can no longer click the action link, wherever I click on the table row, it takes me to whatever I have in the anchor. 但是,我无法再单击操作链接,无论我在表行上单击什么,都将带我到锚点中的所有内容。

That leads me to my question. 这使我想到了我的问题。 How can I make it so that if I click anywhere in the row, it takes me to my anchor, but if I click precisely on the action link, it takes me to where that is set. 如何做到这一点,如果我单击行中的任意位置,它将带我到锚点,但是如果我精确单击动作链接,它将带我到设置的位置。

Any help is greatly appreciated. 任何帮助是极大的赞赏。

Someone has written a plugin for Bootstrap 3 that makes this easy to do. 有人为Bootstrap 3编写了一个插件,使此操作变得容易。 Jasny Bootstrap has "Row Links" which allow you do to the following: Jasny Bootstrap具有“行链接”,可让您执行以下操作:

<tbody data-link="row" class="rowlink">
<tr>
    <td><a href="#wholerow">First Link</a></td>
    <td>Some text</td><td class="rowlink-skip"><a href="#">Action</a></td>
</tr>
</tbody>

where the entire row will link to #wholerow and the <a> tag will link to # 整行将链接到#wholerow ,而<a>标签将链接到#

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM