I am trying to get the value from the first name input and pass it to the bootstrap alert when the user clicks the submit button, but can't manage to do that.
Here is my snippet:
$(document).ready(function() {
$("#submit-button").click(function() {
$("#myAlert").show("fade"), $("#fname").attr("value");
event.preventDefault();
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<label for="fname">First Name</label>
<input type="text" id="fname" name="firstname" placeholder="Your name..">
<div id="myAlert" class="alert alert-success collapse">
<a href="#" class="close" data-dismiss="alert">×</a>Thank you for contacting us,
</div>