?
Solved

setting a hyperlink on a html table's cell value

Posted on 2014-11-06
2
Medium Priority
?
259 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
[X]
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
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 2000 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

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…
This article discusses how to implement server side field validation and display customized error messages to the client.
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
Suggested Courses

765 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