• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 84
  • Last Modified:

reference a html table column with jquery

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
maqskywalker
Asked:
maqskywalker
1 Solution
 
James BilousSoftware EngineerCommented:
$("#table1 tr td:nth-child(3)").append("<a href='http://www.bing.com'>bing.com</a>");

Open in new window

0
 
maqskywalkerAuthor Commented:
thanks
0

Featured Post

Independent Software Vendors: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now