简体   繁体   English

如何使整个表格成为一个按钮/到另一个HTML页面的链接?

[英]How do I make an entire Table a button/link to another HTML page?

I have this table, that should be a button that link to another page. 我有这张桌子,那应该是一个链接到另一个页面的按钮。 The reason is that the values of the table should be changeable with data from a database. 原因是该表的值应随数据库中的数据而更改。 The parameter can be changes to pH for example and the Value to 7 or something. 该参数可以是例如将pH值更改为,将值更改为7或类似值。 But the table/button shall link to the same page. 但是表格/按钮应链接到同一页面。 Where it is possible to set the Target. 可以设置目标的地方。

So far this i what i got: 到目前为止,这是我得到的:

<table class="Button" >
    <tr>
        <td class="parameter"> Temperature</td>
    </tr>

    <tr>
        <td class="Value">23&#x2103</td>    
    </tr>

    <tr>
        <td class="Target">Target: 30&#x2103 </td>
    </tr>
</table>

So how do i make it a link/button? 那么我如何使其成为链接/按钮?

The same way as anything else. 与其他方式相同。

You put an <a> element (with an href attribute) around it. 您在其周围放置一个<a>元素(具有href属性)。

You can use onclick and redirect your page. 您可以使用onclick并重定向页面。

Or wrap your table with <a> 或者用<a>包裹您的桌子

 <table class="Button" onclick="location.href='yourpage.html'" > <tr> <td class="parameter"> Temperature</td> </tr> <tr> <td class="Value">23&#x2103</td> </tr> <tr> <td class="Target">Target: 30&#x2103 </td> </tr> </table> 

Wrap it into a link element: 将其包装到链接元素中:

<a href="LINK.html">
    <table>
        <tr>
            <td class="parameter"> Temperature</td>
        </tr>
        <tr>
            <td class="Value">23&#x2103</td>    
        </tr>
        <tr>
            <td class="Target">Target: 30&#x2103 </td>
        </tr>
    </table>
</a>

And if you wanna have a button, add a button element to that: 如果您想拥有一个按钮,请向其添加一个按钮元素:

<button style="color:black; background-color:white; border-radius:5px;">
    <a href="LINK.html">
        <table>
            <tr>
                <td class="parameter"> Temperature</td>
            </tr>
            <tr>
                <td class="Value">23&#x2103</td>    
            </tr>
            <tr>
                <td class="Target">Target: 30&#x2103 </td>
            </tr>
        </table>
    </a>
</button>

You can do it using javascript onClick event or put <a> tag around it 您可以使用javascript onClick事件或在其周围放置<a>标记来完成此操作

Html HTML

 <table class="button" onClick="linkTo('https://www.google.com')">
    .
    .
    .
 </table>

Java Script Java脚本

<script>
       function linkTo(var link){
         window.location = link;
       }

</script>

Css for mouse point 鼠标指针的CSS

<style>
 table.button{
     cursor: pointer;
  }
</style>

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

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