Unreal value when condition change
<p>I use the following code to check whether there are sub elements inside a parent element. </p>

<pre><code>var parentTopCoordinate = $('#bill-list').offset().top;
var elementCoordinate = $(elem).parent().position().top;

$('#bill-list').find(".bill-item-list").each(function () {
    if ($(this).css("display") == "block" &amp;&amp; $(this).find(".bill-item").length &gt; 0) {
        elementCoordinate = elementCoordinate - 320;
    } else if (($(this).find(".bill-item").length) == 0) {
        elementCoordinate = elementCoordinate - 100;
    }
});
</code></pre>

<p>in the second condition, when I use <code>"=="</code> the elementCoordinate gets an unreal minus value! But if I use <code>"&lt;"</code> for the condition, the right values come! why is this happening!</p>

<p>Update : HTML</p>

<pre><code>&lt;div id="bill-list"&gt;
    &lt;div id="bill-panel"&gt;
        &lt;!-- Bill --&gt;
        &lt;div class="bill"&gt;
            &lt;!-- Bill description - Holds Bill details --&gt;
            &lt;div class="bill-description"&gt;
                &lt;div class="bill-info bill-number"&gt;&lt;span&gt;000A&lt;/span&gt;&lt;/div&gt;
                &lt;div class="bill-info table-name"&gt;&lt;span&gt;TABLE 78&lt;/span&gt;&lt;/div&gt;
                &lt;div class="bill-info room-number"&gt;&lt;span&gt;A678&lt;/span&gt;&lt;/div&gt;
                &lt;div class="bill-info amount"&gt;&lt;span&gt;76.00&lt;/span&gt;&lt;/div&gt;
                &lt;div class="bill-remove-icon"&gt;&lt;/div&gt;
            &lt;/div&gt;
            &lt;!-- Bill Item list --&gt;
            &lt;div class="bill-item-list"&gt;
                &lt;!-- Item : This is a sample element &amp; will be cleared when system loads --&gt;
                &lt;div class="bill-item"&gt;
                    &lt;!-- Item image --&gt;
                    &lt;div class="bill-item-img"&gt;&lt;/div&gt;
                    &lt;!-- Item description --&gt;
                    &lt;div class="bill-item-description"&gt;
                        &lt;div class="bill-item-name"&gt;
                            &lt;!-- Item Name --&gt;
                            &lt;p class="bill-item-name-left"&gt;Normal Cofee&lt;/p&gt;
                            &lt;!-- Item Price --&gt;
                            &lt;p class="bill-item-name-right"&gt;170.00&lt;/p&gt;
                            &lt;div class="clear"&gt;&lt;/div&gt;
                        &lt;/div&gt;
                        &lt;!-- Total item price --&gt;
                        &lt;div class="bill-item-price"&gt;&lt;span&gt;170.00&lt;/span&gt;&lt;/div&gt;
                        &lt;!-- Item Quantity --&gt;
                        &lt;div class="bill-item-amount"&gt;&lt;span&gt;1&lt;/span&gt;&lt;/div&gt;
                    &lt;/div&gt;
                    &lt;!-- Increas &amp; Decrease item Quantity --&gt;
                    &lt;div class="bill-amount-selection"&gt;
                        &lt;a class="amount-increase" href="#"&gt;&lt;/a&gt;
                        &lt;a class="amount-decrease" href="#"&gt;&lt;/a&gt;
                    &lt;/div&gt;
                &lt;/div&gt;
                &lt;!-- Remove bill link --&gt;
                &lt;div class="item-drop-point"&gt;&lt;/div&gt;
            &lt;/div&gt;
        &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>
