Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
-5
rated 0 times [  2] [ 7]  / answers: 1 / hits: 20037  / 12 Years ago, sat, september 22, 2012, 12:00:00

I have this js part of script:



jQuery.each(data, function(index, value) {
$(table_div).append(<td> + value + </td>);
});


I want use this for create a table with twitter bootstrap. In the html page there is this table element:



<table class=table table-striped id=table_div>
</table>


But this solution doesn't works. How I have to do? Thank you!


More From » jquery

 Answers
242

First of all, you're not appending any <tr> elements which are needed in a table, and secondly you're referring to $(table_div) instead of $(#table_div) (the hashtag # means that you're referring to an ID, just like in CSS).



jQuery.each(data, function(index, value) {
$(#table_div).append(<tr><td> + value + </td></tr>);
});

[#82955] Thursday, September 20, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
cristinadomoniquel

Total Points: 320
Total Questions: 94
Total Answers: 94

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
cristinadomoniquel questions
Wed, Apr 7, 21, 00:00, 3 Years ago
Tue, Dec 1, 20, 00:00, 4 Years ago
Mon, Nov 23, 20, 00:00, 4 Years ago
Mon, Aug 17, 20, 00:00, 4 Years ago
;