Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code>if ('#description' === '') { ... } </code></pre> <p>This compares two literal strings which are obviously not equal to each other, thus always giving a <code>false</code> result. You'll need to retrieve the <code>#description</code> element and retrieve some information about it.</p> <p>There are quite a few ways you could go about this:</p> <ul> <li><code>if ($('#description').html() === '') { ... }</code><br/>This will match if the HTML content of the <code>#description</code> element is empty. Text nodes and comments are retained.</li> <li><code>if ($('#description').text() === '') { ... }</code><br/>This will match if the text content of the <code>#description</code> element is empty. (The text content is its "flat" content, e.g. the HTML tags are stripped off.) Comments are discarded.</li> <li><code>if ($('#description').children().length === 0) { ... }</code><br/>This will match if the <code>#description</code> element has no child elements. Text nodes and comments are not considered, i.e. <code>&lt;div id="description"&gt;Foo &lt;!-- Bar --&gt;&lt;/div&gt;</code> has no child nodes according to this method.</li> </ul> <p>If you know you only need to worry about actual child nodes (e.g. an <code>&lt;img&gt;</code> tag), <code>.children().length</code> is probably the easiest choice. Otherwise, you'll have to look at the actual text contents and possibly <code>.trim()</code> it before checking if its <em>truly</em> empty:</p> <pre><code>if ($('#description').text().trim() === '') { ... } </code></pre> <p>or equivalently:</p> <pre><code>if ($('#description').text().trim().length === 0) { ... } </code></pre>
    singulars
    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. This table or related slice is empty.
    1. This table or related slice is empty.
    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