I am trying to create an interactive form using HTML and JQuery. The idea is for the user to type their name, email, and comment. Then, the input from the user would be appended to an HTML paragraph and displayed on the form. I was able to create the form, but am having trouble displaying the user's input. Any help is greatly appreciated!
Here is the code I have:
$("form").submit(function(event) {
var user_name = $('#form').find('input[name="name"]').val();
var user_email = $('#email').val();
var user_comment = $('#comment').val();
$("p.feedback").append("user_name");
});
h1 {
text-align: center;
}
.aligncenter {
text-align: center;
}
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<h1 style="border: 2px solid black;
background-color: white;" " > </h1>
<div style = "border: 2px solid black; background-color: white; padding: 25px 50px; "">
<h2>Biography</h2>
<p> </p>
<h2>Education</h2>
<p> </p>
<h2>Research Interests</h2>
<p> </p>
<h2>Contact Information</h2>
<p> </p>
</div>
<form>
<label for="name">Name:</label><br>
<input type="text" id="name" name="name"><br>
<label for="email">Email:</label><br>
<input type="text" id="email" name="email"><br>
<label for="comment">Comment:</label><br>
<input type="text" id="comment" name="comment"><br>
<input type="submit" value="Submit">
</form>
<p class="feedback"></p>