views:

28

answers:

2

Hello all,

I am trying to place some html within a td that has an id but this doesn't seem to work. Can JQuery not put html in a td by using its id as a selector??

I do this:

$('#total_match').html("<b>Test</b>");

Here is the td:

<td id="total_match"></td>

No errors occur and nothing appears in the TD - I view the source to confirm.

I appreciate any help.

A: 
$('<table><tr><td id="lol"></td></tr></table>').appendTo('body').find('#lol').html('<b>test</b>')

Works fine for me. Double check and make sure you dont have duplicate ids and are selecting the proper things.

meder
I have made sure those ids are unique, the funny thing is that there is another function that does the same thing after an ajax request but it can't do it again after a refresh!
Abs
+2  A: 
  1. Are you sure your ID is unique in the document, maybe jQuery is filling another element with the same ID
  2. Are you running the code above inside the jQuery ready event? If not, your DOM may not be fully loaded and the TD does not exist while executing your Javascript

Example:

$(document).ready(function()
{
    $('#total_match').html("<b>Test</b>");
});
Vincent Robert
1) ID is unique, i checked several times! 2) The page is fully loaded and I wait 5 seconds before testing my function. I also use firebug to determine if its there.
Abs
Actually number 2 was my problem! Thank you!
Abs