Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>jQuery appends elements , not the literal text...since it's immediately appended to the DOM the way you're currently doing it, you'll get some very funny behavior, since you're starting with unclosed tags (which it closes for you to prevent errors).</p> <p>You just need to change your approach a bit, but doing it right also means even <em>less</em> code, like this:</p> <pre><code>var row = $('&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;/tr&gt;&lt;/thead&gt;&lt;/table&gt;').find('tr'); for(var i=0; i&lt;=6; i++) { $('&lt;td /&gt;', { text: week[i] }).appendTo(row); } row.end().appendTo('#calendar');​ </code></pre> <p><a href="http://jsfiddle.net/wxcD8/" rel="nofollow noreferrer">You can view a working demo here</a>, this creates the table using <a href="http://api.jquery.com/jQuery/" rel="nofollow noreferrer"><code>$(html)</code></a>, a document fragment, we then <a href="http://api.jquery.com/find/" rel="nofollow noreferrer"><code>.find()</code></a> the row and keep a handy reference to it, create the <code>&lt;td&gt;</code> elements one by one using <a href="http://api.jquery.com/jQuery/" rel="nofollow noreferrer"><code>$(html, props)</code></a>, and add them to the row using <a href="http://api.jquery.com/appendTo/" rel="nofollow noreferrer"><code>.appendTo()</code></a>. After we've added them all, call <a href="http://api.jquery.com/end/" rel="nofollow noreferrer"><code>.end()</code></a> to change the chain to what it was before the <a href="http://api.jquery.com/find/" rel="nofollow noreferrer"><code>.find()</code></a> was called...in this case the entire <code>&lt;table&gt;</code>, then just append that table to the <code>#calendar</code> element :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload