:last not only remove last element
<p>I'm trying to make my own search name, a facebook-like-search (autocomplete), as in facebook's compose message. My whole script is at <a href="http://jsfiddle.net/6YbrP/4/" rel="nofollow">http://jsfiddle.net/6YbrP/4/</a>.</p>

<p>The problem is I'm stucked at this code :</p>

<pre><code>.keyup(function(e){
            if(e.keyCode == 8 &amp;&amp; $(this).val() == ''){
                $('#itemcontainer div.detailwrapper:last').remove();
            }
        });
</code></pre>

<p>It does remove the last element, IF I just clicked the box and then press backspace button. BUT NOT when I clicked inside the box, then clicked outside the box, clicked inside the box again, and re-press backspace key. It deleted/ removed 2 last elements, not only the last element. How could this happen? And how could I fixed it?</p>

<p>Thank you for any responses.</p>
