Cptn_Hammer Cptn_Hammer - 4 months ago 31
CSS Question

Make row item a clickable link in bootstrap

I'm trying to make a site using bootstrap where one row of a table will be clickable. ie, I want it to show me text (click here for Stackoverflow) such that when the user clicks in that table row, they are directed to http://stackoverflow.com.

Note that I do not want just the text to act as a hyperlink; that would be trivial. I am trying to make the entire .row element a hyperlink.

The code is just standard bootstrap tables.

<div class="col-md-3">
<div class="row">
<p>Text here</p>
<div class="row">
<p>More text</p>

Things I have tried:
I have tried adding a transparent picture on top of the row, and after wrangling with the positioning, ended up setting it as the background image of the row. Now it doesn't show up, and even if it did, still wouldn't act as a link.

Novice to bootstrap, willing to try almost any approach.


You should make a div with an id that you can use in Javascript like this:

<div id='clickme'></div>

Then you should import the Javascript you are about to make like this:

<script type='text/JavaScript' src='yourFile.js'></script>

Then you should make a method in your .js file that is in the same directory as you html page that looks like this:

var myMap = document.getElementById("clickme");
myMap.onclick = function() {
	var myVar = window.open("https://www.stackoverflow.com");

I am 100% this will work for you. This will let you cover whatever area you want with this div you made and if anything inside of it is clicked then it will open a new tab with stackoverflow.