Solved

reference a html table column with jquery

Posted on 2016-08-30
2
55 Views
Last Modified: 2016-08-30
I have a html table that looks as shown on this code.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>

    <script src="http://code.jquery.com/jquery-1.10.1.js"></script> 

    <style type="text/css">

        #table1 {
            border: solid 1px #000000;
        }

    </style>
    

    <script type="text/javascript">
        $(document).ready(function () {
            // -------------------


            
            // -------------------
        });

    </script>
    
</head>
<body>

    <div>

        <table id="table1">

            <tr>
                <td>
                    <span>Google</span>
                </td>
                <td>
                    <span>Yahoo</span>
                </td>
                <td>
                    <span>Bing</span>
                </td>
            </tr>
        </table>
    </div>

</body>
</html>

Open in new window


On page load, I'm trying to use jquery to do the following.

on jquery page load event,
Look in the third column of the table with id of table1, and add a hyperlink to the text in that cell.
The hyperlink for the link in the third column should point to: http://www.Bing.com

So the rendered html for the table should look like this:

        <table id="table1">

            <tr>
                <td>
                    <span>Google</span>
                </td>
                <td>
                    <span>Yahoo</span>
                </td>
                <td>
                    <span><a href="http:www.Bing.com">Bing</a></span>
                </td>
            </tr>
        </table>

Anyone know the jquery syntax for this?
0
Comment
Question by:maqskywalker
2 Comments
 
LVL 8

Accepted Solution

by:
James Bilous earned 500 total points
ID: 41776951
$("#table1 tr td:nth-child(3)").append("<a href='http://www.bing.com'>bing.com</a>");

Open in new window

0
 
LVL 1

Author Closing Comment

by:maqskywalker
ID: 41777112
thanks
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Suggested Solutions

Title # Comments Views Activity
How to create a slidershow with the use of the property cover in css 15 46
JQuery Syntax... 4 33
How to create a table with buttons 3 21
Search Item in Table 2 19
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

856 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