jQuery's blur() and selector problem

Posted by matthewayinde on Stack Overflow See other posts from Stack Overflow or by matthewayinde
Published on 2010-03-27T12:52:10Z Indexed on 2010/03/27 13:03 UTC
Read the original article Hit count: 323

Filed under:
|

I'm trying to create a new div each time a text field contained in the last div loses focus, but a new div is added only when the text field in the first div loses focus (instead of the last)... Please I need help urgently. Thanks a lot. Here's my code:

    $(function() {
          $(':text:last').blur(function() {
            $('<div class="line"><span>data: </span><input type="text"/></div>')
            .appendTo($('#lineStack'));
        });
    }); 

HTML:

<div id="lineStack">
    <div class="line">
        <span>data: </span><input type="text" />
    </div>
</div>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about blur