我似乎无法获得jquery .submit方法来执行。我感觉这是一个愚蠢的错误,但我已经被困了几个小时。任何想法都错了吗?
HTML:
<form id="contactform" action="sendEmail.php">
<div class="form-group" action="" method="post">
<label for="Email" class="sr-only">Email address</label>
<input type="email" class="form-control" name="Email" id="Email" placeholder="Email" required/>
</div>
<div class="form-group">
<label for="Name" class="sr-only">Name</label>
<input type="text" class="form-control" name="Name" id="Name" placeholder="Name" required/>
</div>
<div class="form-group">
<label for="Message" class="sr-only">Message</label>
<textarea class="form-control" rows="5" name="Message" placeholder="Message" required/></textarea>
</div>
<button type="submit" value="submit" class="pillButton" ><i class="fa fa-paper-plane"></i> Send</button>
</form>
Jquery的:
alert("outside submit function"); // Works
$("#contactform").submit(function(event) { // Event not working
event.preventDefault();
alert( "Handler for .submit() called." );
});