Help using jQuery to replace table cell contents with image

I'd like to replace the third cell of a table row with an image.  Below is what my table looks like.  I also have the code below but it's not working.

<table summary="Rating Scale Question">
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>

<script type="text/javascript">
$(document).ready(function () {
	$('table[summary='Rating Scale Question'] tr:first-child td:nth-child(2)').each(function () {
          $(this).html('<img src="path-to-my-images/smiley_poor.png" alt="Poor" />');
    }
}
</script>

Open in new window

greddinAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

greddinAuthor Commented:
Just to clarify.  I want to replace the contents of the table cell and not the element itself.

The final output would be something like this:

<td><img src="my image.png"></td>

Thanks.
Chris StanyonWebDevCommented:
You've got a slight issue with your single quotes. You also don't need to each it or call first-child on the <tr>. Finally nth-child is one-based, not zero-based, so the third column is 3

$('table[summary="Rating Scale Question"] tr td:nth-child(3)')
    .html('<img src="path-to-my-images/smiley_poor.png" alt="Poor">');

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chris StanyonWebDevCommented:
Actually, if you only want to change the 3rd TD in the first row, then you would need first-child on the tr. My previous code assumed you wanted to set the content for the 3rd TD in each row.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

greddinAuthor Commented:
Thanks, so I've got this now but it's not working.  Am I missing a parenthesis somewhere?

<script type="text/javascript">
$(document).ready(function () {
$('table[summary="Rating Scale Question"] tr td:nth-child(3)').html('<img src="https://f001.backblazeb2.com/file/greg-hp-public/images/smiley_poor.png" alt="Poor">');
}
</script>

Open in new window

greddinAuthor Commented:
Nevermind, I was missing the closing  "});".
greddinAuthor Commented:
Thanks Chris!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.