Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

setting a hyperlink on a html table's cell value

Posted on 2014-11-06
2
238 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 24

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

809 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