Note that there are some explanatory texts on larger screens.

plurals
  1. POgetting JQuery .height() after appending to another div returns 0
    text
    copied!<p>I am trying to create a div that is scrollable only when it's above a certain height after appending text to it. I check the height using jquery and it returns zero every time. Any suggestions?</p> <pre><code>HelpOverlay.prototype.buildContent = function(helpMappings){ this.content = $('&lt;div class="content"&gt;&lt;/div&gt;'); var table = $('&lt;table&gt;&lt;/table&gt;'); table.append($('&lt;tr&gt;&lt;td class="key"&gt;&lt;h3&gt;Key&lt;/h3&gt;&lt;/td&gt;&lt;td class="command"&gt;&lt;h3&gt;Command&lt;/h3&gt;&lt;/td&gt;&lt;/tr&gt;')); this.content.append(table); for (var whichCategory = 0; whichCategory &lt; helpMappings.categories.length; whichCategory++) { var category = helpMappings.categories[whichCategory]; var categoryDiv = $('&lt;div class="category"&gt;' + category.category + '&lt;/div&gt;'); this.content.append(categoryDiv); var categoryTable = $('&lt;table&gt;&lt;/table&gt;'); for (var whichMapping = 0; whichMapping &lt; category.mappings.length; whichMapping++) { var mappings = category.mappings[whichMapping]; var row = $('&lt;tr&gt;&lt;/tr&gt;'); var keyCell = $('&lt;td class="key"&gt;' + mappings.key + '&lt;/td&gt;'); var commandCell = $('&lt;td class="command"&gt;' + mappings.command + '&lt;/td&gt;'); row.append(keyCell); row.append(commandCell); categoryTable.append(row); } this.content.append(categoryTable); } this.helpOverlay.append(this.content); console.log(this.content.height()); } </code></pre> <p>console.log(this.content.height()) is returning zero. </p>
 

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