I'm trying to insert a new textfield on a page each time user presses enter.
My code
$(":text").on("keypress", function(e) {
if (e.keyCode == '13') {
e.preventDefault()
$(this).after("<p><input type='text' class='textfield' maxlength='10' value=''/> <span></span> </p>")
}
});
A new text field appears when I press enter on orginal text field, but the new one does not react any presses. I assume on-function is similar to live, which should be a fix to this kind of problems. What's wrong?