Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery append doesn't work with <tr> tag

I'm trying to append to this code:

<table class="stores" border="1" cellspacing="10">
    <tr>Stores:</tr>
</table>

This code, which I want to work, doesn't:

$('.stores').append('<tr>Test</tr>');

This one does work:

$('.stores').append('<p>Test</p>');

Can you say why?

P.S. Not sure it matters but I'm working under WordPress.

like image 446
Ash Avatar asked May 19 '26 11:05

Ash


2 Answers

You can't have text between tr-tags. Try this:

$('.stores').append('<tr><td>Test</td></tr>');
like image 150
Andreas Eriksson Avatar answered May 21 '26 00:05

Andreas Eriksson


That's not valid HTML. You're missing the <td>

Works fine when you change the markup : http://jsfiddle.net/jomanlk/XHvVk/

$('.stores').append('<tr><td>Test</td></tr>');
like image 38
JohnP Avatar answered May 21 '26 01:05

JohnP