【发布时间】:2017-02-07 18:11:46
【问题描述】:
我有一个关于我在我的网站上尝试的代码的问题。我想最小化文字的大小,所以我尝试通过简单的点击来隐藏对象。但这确实总是提交我的表单。
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#hide").click(function(){
$("table").hide();
});
$("#show").click(function(){
$("table").show();
});
});
</script>
</head>
<body>
<table style="border:solid #FFFFFF 2px;
background-color:#0000ff;height:1px;width:300px;
text-align:left;" "empty-cells:hide;" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>Test</th>
<th>Extras</th>
<th>Extras</th>
</tr>
</table>
<br>
<button id="hide">Hide</button>
<button id="show">Show</button>
</body>
</html>
[submit class:button id:form-submit "Send"]
【问题讨论】:
-
您的 HTML 中没有可以提交的
<form>元素...? -
您的代码运行良好。单击隐藏/显示按钮是否提交了您的表单?
-
嗨!是的,单击隐藏显示按钮确实提交了我的表单。现在还使用了一个接受框来添加一个条件,这样它就不会立即发送它
-
大家好,感谢您的帮助,并为迟到的回复感到抱歉。我找到了另一种更简单的方法。
标签: javascript jquery html forms contact-form-7