jQuery's blur() and selector problem
- by matthewayinde
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>