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 declare and print value of variable in JavaScript?
JavaScript HTML5 Validation for name and email field
How can I redirect the user from one page to another using jQuery or pure JavaScript?
Check if a string ends with the given target string
Using jQuery add new table row on click
How to change text color on click using JavaScript?
How to change text after click event using JavaScript?
jQuery move multi select values from one to another multi select list
jQuery simple form with name and email validations
ES6 method of declaration multiple variables in one line