Html 按钮和输入的区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4488317/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between button and input?
提问by DarkLightA
Are there any major differences between <button type="button" name="theButton">SUBMIT</button>
and <input type="submit" value="SUBMIT" name="theButton" />
<button type="button" name="theButton">SUBMIT</button>
和之间有什么主要区别吗<input type="submit" value="SUBMIT" name="theButton" />
Also, can you use <button type="submit" name="theButton">SUBMIT</button>
?
另外,你能用<button type="submit" name="theButton">SUBMIT</button>
吗?
采纳答案by Zain Shaikh
Here's a pagedescribing the differences (basically you can put html into a <button></button>
这是一个描述差异的页面(基本上您可以将 html 放入<button></button>
And an other pagedescribing why people avoid <button></button>
(Hint: IE6)
另一个页面描述了人们为什么避免使用<button></button>
(提示:IE6)
Reference: <button> vs. <input type="button" />. Which to use?
参考:<button> 与 <input type="button" />。使用哪个?
Also have a look at this slideshow about button.
也看看这个关于 button 的幻灯片。
回答by Quentin
<button type="button" name="theButton">SUBMIT</button>
<button type="button" name="theButton">SUBMIT</button>
Won't submit a form (bugs in some browsers aside)
不会提交表单(除了某些浏览器中的错误)
<input type="submit" value="SUBMIT" name="theButton" />
<input type="submit" value="SUBMIT" name="theButton" />
Will submit a form.
将提交表格。
Also, can you use
<button type="submit" name="theButton">SUBMIT</button>
?
另外,你能用
<button type="submit" name="theButton">SUBMIT</button>
吗?
Will submit a form, but doesn't have a value (bugs in IE aside)
将提交表单,但没有值(IE 中的错误除外)