Solved

setting a hyperlink on a html table's cell value

Posted on 2014-11-06
2
242 Views
Last Modified: 2014-11-07
I have a html table that looks like this:

http://jsfiddle.net/hmt7nk1d/

Is there a way, either with CSS or with javascript to set a hyperlink for the values contained in the TeamWebsite column.

So If I click on any row in the TeamWebsite column I will be taken to that url.
So for example if I click on the falcons url it will take me to that url?
0
Comment
Question by:maqskywalker
2 Comments
 
LVL 25

Expert Comment

by:chaau
ID: 40427587
The hyperlinks are created using an <a> tag, like this:
<a href="http://www.azcardinals.com">click me</a>
<a href="http://www.azcardinals.com">http://www.azcardinals.com</a>
Check it out
BTW, I think you do not need the "Team WebSite" column altogether. Just use the TeamName column, like this
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40427589
Use :
var rows = document.getElementById("table1").getElementsByTagName("tr");
    for(var i=1;i<rows.length;i++) {
        rows[i].getElementsByTagName("td")[4].onclick = function() {
            var src = this.innerHTML;
            location.href = src;
        }
    }

Open in new window


or this if you've jQuery :
jQuery(function($) {
    $("tr:gt(0) td:eq(4)", "#table1").click(function() {
        location.href = $(this).text();
    });
});

Open in new window

0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question