Solved

setting a hyperlink on a html table's cell value

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
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 the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

695 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