简体   繁体   English

如何使整个表格行可点击?

[英]How to make whole table row clickable?

I have searched this site for a better solution on this but it seems that I can't find the right one.我已经在此站点上搜索了更好的解决方案,但似乎找不到合适的解决方案。

I want to make my whole table row clickable in case of PC and also same thing should happen when user touches anywhere inside the row in case of tablet.我想让我的整个表格行在 PC 的情况下可点击,并且在平板电脑的情况下,当用户触摸行内的任何地方时也会发生同样的事情。 So far I have the following code and I would prefer a Html or JavaScript solution or anything along those lines.到目前为止,我有以下代码,我更喜欢 Html 或 JavaScript 解决方案或任何类似的东西。

<tr onclick="window.document.location='';">
  <td><img src="/chemsolver/images/help.jpeg" alt="" width="36" height="36"    id="Synthesis2" style="background-color: #996633" align="right" /></td>
  <td><a href="/chemsolver/help.php"> Help With Table </a></td>
</tr>

Set display: block on the anchor tag.在锚标签上设置display: block And then set your height on the anchor.然后在锚点上设置你的高度。

http://jsfiddle.net/u2qLC/ http://jsfiddle.net/u2qLC/

Alternatively use an onclick event on the tr and have cursor: pointer set on the tr.或者在 tr 上使用 onclick 事件并在 tr 上设置cursor: pointer Instead of using anchor tag.而不是使用锚标记。

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

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