jQuery append example

Método append jquery Com Add em linhas separadas

by NunoMira

HTML

<div>
		<label>Insere aqui o teu nome:</label>
		<input id="nome" type="text">
</div>

<br>

<div>
	<label>Insere aqui o teu clube:</label>
	<input id="clube" type="text">
</div>

<br>

<div>
  <button>Adicionar linha com informação</button>
</div>

<br>
<br>

<div>
	<label style="margin-bottom: 6px;">Resultado:</label>
	<div id="final">
	</div>
</div>

JavaScript

// handle click
$("button").on("click", function()
{
		var nome = $("#nome").val();
		var clube = $("#clube").val();
		
		var htmlLineStr = '<div style="border: 1px solid black; width: 300px; height: 21px; margin-bottom: 4px;">'+nome+'</div>'+
											'<div style="border: 1px solid black; width: 300px; height: 21px; margin-bottom: 4px;">'+clube+'</div>'+
											'<br>';
											
		$("#final").append(htmlLineStr);
})