jQuery show input text inside div after on click event

Add some text in input box and click on Add Message button:

Example

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
function showMessage() {
    var message = jQuery("#textToDisplay").val();
    jQuery("#messageSpan").text(message);
}
</script>
</head>
<body>
<input type="text" id="textToDisplay" />
<input type="button" value="Add message" onClick="showMessage()" />
<div>
	<span id="messageSpan"><span>
</div>
</body>
</html>
Most Helpful This Week