Solved

reference a html table column with jquery

Posted on 2016-08-30
2
62 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 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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
Boolean 13 46
Do I need to force my browser to see my new Favicon 4 42
Horizontal Full Calendar using php 5 39
html link offset in page with umlaut character in address 5 29
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…
This article discusses how to implement server side field validation and display customized error messages to the client.
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 how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

739 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