Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

reference a html table column with jquery

Posted on 2016-08-30
2
Medium Priority
?
80 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
[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 9

Accepted Solution

by:
James Bilous earned 2000 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

636 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