I have an h2 element which has styled content (css) inside this I also have a span element called highlight. I want to update this with a text input on the submit button being clicked.
the result I get (on click) is the original text clears out, then is refreshed into the span again so it still shows "John Smith".
//index.html
<span id="highlight">John Smith</span>
<form action="" class="form-inline">
<input id="name" type="text" placeholder="Enter name" size="35">
<input type="submit" value="Submit" class="button-btn">
</form>
//app.js
$(function(){
let name = $('#name').val();
$('.button-btn').click(function(){
$('#highlight').text(name);
});
});
Its getting frustrating as I think I am doing it right, but obviously not. Thank you in advance for a resolution.