 <p><code>this</code> is always a local variable and therefore it is overwritten in every function.</p> <p>What you might do is pointing to your class e.g. <code>var myClass = this;</code> and use <code>myClass</code> instead of <code>this</code>.</p> <pre><code> this.checkSections = function(){ var myClass = this; jQuery('#droppable #section').each( function() { nextId = jQuery(this).next().attr('id'); if (nextId != 'small' &amp;&amp; nextId != 'large'){ jQuery(this).remove(); myClass.sections --; myClass.followArticles = 0; }else{ articles = 0; obj = jQuery(this).next(); while (nextId == 'small' || nextId == 'large'){ articles++; obj = obj.next() nextId = obj.attr('id'); //alert(nextId); } myClass.followArticles = articles; alert(myClass .sections); } }); } </code></pre>