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
How to define Global Variable in JavaScript?
How to declare and print value of variable in JavaScript?
jQuery simple form validations between start date and end date
How to check if an element or HTML tag exists using JavaScript?
Using jQuery delete table row on click
Write a function that splits an array into groups the length of size and returns them as a two-dimensional array