Jump to content

frontend get hyperlink on whole table row

Joveice

Hello,

 

Looking for a way to turn a whole row of a table into a link in html. I have looked a bit and I found a two ways, non works for me.

 

A link on each cell: This is just a mess and a link at the end would be better.

A on click: This does not look bad, but I have not found a way to be able to do ctrl + click on that.

 

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

Give all the table cells a class. Add an event listener for that class for click. In the event listener check if keycode 17 is being pressed for control click

I am good at computer

Spoiler

Motherboard: Gigabyte G1 sniper 3 | CPU: Intel 3770k @5.1Ghz | RAM: 32Gb G.Skill Ripjaws X @1600Mhz | Graphics card: EVGA 980 Ti SC | HDD: Seagate barracuda 3298534883327.74B + Samsung OEM 5400rpm drive + Seatgate barracude 2TB | PSU: Cougar CMX 1200w | CPU cooler: Custom loop

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Hazy125 said:

Give all the table cells a class. Add an event listener for that class for click. In the event listener check if keycode 17 is being pressed for control click

Thanks

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

<table>
  <a href=#>
  <tr>
    <td>cell</td>
    <td>cell</td>
  </tr>
  </a>
</table>

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

2 hours ago, vorticalbox said:

<table>
  <a href=#>
  <tr>
    <td>cell</td>
    <td>cell</td>
  </tr>
  </a>
</table>

 

This does not work, and it's not valid and will give flags in any IDE :P

Back-end developer, electronics "hacker"

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Joveice said:

This does not work, and it's not valid and will give flags in any IDE :P

Tried on jsfiddle, I thought that might work lol my bad and no one cares about "flags in IDE", they should but they don't if it works it works.

 

<table>
<tr onclick="change()" style="cursor: pointer;"><td>Cell 1</td><td>Cell 2</td></tr>
<tr><td>Cell 1</td><td>Cell 2</td></tr>
</table>
<script>
function change(){
	alert('You clicked me!')
}
</script>

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×