.submit(handler)Jquery无法正常工作

时间:2015-10-01 20:09:32

标签: javascript jquery html submit

我似乎无法获得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." );
});

1 个答案:

答案 0 :(得分:1)

这可能是你所缺少的 - 一个加载包装器:

FIDDLE

strtoul()