Solved

reference a html table column with jquery

Posted on 2016-08-30
2
37 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 7

Accepted Solution

by:
James Bilous earned 500 total points
Comment Utility
$("#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
Comment Utility
thanks
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now