var emails = $("input[type=email]"), total = emails.length; $("#add").click(function(){ var div = $("<div></div>"), label = $("<label></label>"), email = $("<input type = email />"); label.html("Email " + (++total) + ":"); div.append(label, " " , email); $("section").append(div); emails = $("input[type=email]"); email.focus(); if (total == 5) this.disabled = true; }); $("#fin").click(function(){ var valores = []; for (i = 0; i < total; i++) valores.push(emails[i].value); if (valores.length) $("p").html(valores.join(", ")); });
<section> <div> <label>Email 1:</label> <input type = "email" autofocus /> </div> </section> <button id = "add">AƱadir otro</button> <button id = "fin">Clic</button> <p></p>