Agregar Divs

.val() vs .text()

by Jelgab

HTML

<h3>
Agregar Divs
</h3>

<div id = "Resultados" >
  &nbsp;
</div>
<hr/>

<label id = "elLabel">Entre el valor:</label>
<input id = "txtValue" type = "text" />
<button type = "button" onclick = "mostrarValor()">Mostrar Valor</button>

JavaScript

//Agregar Divs
console.clear();

function printResults( theValue ){
   $("#Resultados").append( theValue );
   $("#Resultados").append( $("<br/>") );
}

function mostrarValor(){
	printResults( $( "#txtValue").val() );
	printResults( $( "#elLabel").text() );
  console.log( "Texto:" + $( "#txtValue" ).length );
}