我正在尝试制作一个简单的时事通讯注册表单,其中包含一个电子邮件地址字段和提交按钮。当用户输入他们的地址并点击提交时,我希望在表单下方显示一条确认消息。实际发生的是消息出现并立即消失。我如何让它保持原样?这是我的代码:
<body>
<form id="newsletter_signup"> <!-- form action to be added later -->
<p><input type="text" name="email" id="email" placeholder="your@email.com" />
<input type="submit" value="Subscribe"></p>
<div id="feedback"></div>
</form>
</body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script>
$('#newsletter_signup').submit(function() {
var email_address = $('#email').val();
$('#feedback').html('Thanks! ' + email_address + ' has been signed up.');
});
</script>