我有一个使用jquery隐藏的表单,点击显示。我想使用php发布数据,但点击提交没有任何反应。请参阅代码
<div class="col-12 col-sm-2 with-click-text">
<form name="contactform" method="post" action="">
<table class="click-text font-light "width="450px" >
<tr>
<td>
<label for="first_name">First Name *</label>
<input type="text" name="first_name" maxlength="50" size="30">
<label for="last_name">Last Name *</label>
<td valign="top"> <input type="text" name="last_name" maxlength="50" size="30">
<label for="email">Email Address *</label>
<input type="text" name="email" maxlength="80" size="30" required>
<label for="telephone">Telephone Number</label>
<input type="text" name="telephone" maxlength="30" size="30">
<label for="comments">Comments *</label>
<textarea name="comments" maxlength="1000" cols="25" rows="6" required></textarea>
<input type="submit" name="mailit" id="submit" value="Submit">
</form>
</td>
</tr>
</table>
</div>
if(isset($ _ POST ['mailit'])){echo“做某事”;}
$('.with-click-text').click(
function(e) {
$(this).css('overflow', 'visible');
$(this).find('.click-text')
.show()
.css('opacity', 0)
.delay(200)
.animate(
{
paddingTop: '25px',
opacity: 1
},
'fast',
'linear'
);
$("#submit").on("click",function(e){
$(this).submit();
});
});
答案 0 :(得分:1)
您没有ID为submit
的元素。更新你的功能;
....
$("input[type='submit']").on("click",function(){
event.preventDefault();
$(this).submit();
});
您可以在此处查看演示: Demo