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>
Answered: Thanks Nick! Your answer worked. I've been trying to mark your post as answer but it's not working. Don't know why :)