输入类型=“提交"VS 按钮标签它们可以互换吗?

编程入门 行业动态 更新时间:2024-10-27 15:29:56
本文介绍了输入类型=“提交"VS 按钮标签它们可以互换吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

input type="submit" 和 button 标签是否可以互换?或者如果有什么不同,那么什么时候使用 input type="submit" 和 button 什么时候?

input type="submit" and button tag are they interchangeable? or if there is any difference then When to use input type="submit" and when button ?

如果没有区别,那么为什么我们有 2 个用于相同目的的标签?

And if there is no difference then why we have 2 tags for same purpose?

推荐答案

www.w3/TR/html4/interact/forms.html#h-17.5

使用 BUTTON 元素创建的按钮功能与使用 INPUT 元素创建的按钮一样,但它们提供了更丰富的呈现可能性:BUTTON 元素可能有内容.例如,包含图像的 BUTTON 元素功能类似于并且可能类似于类型设置为图像"的 INPUT 元素,但 BUTTON 元素类型允许内容.

Buttons created with the BUTTON element function just like buttons created with the INPUT element, but they offer richer rendering possibilities: the BUTTON element may have content. For example, a BUTTON element that contains an image functions like and may resemble an INPUT element whose type is set to "image", but the BUTTON element type allows content.

因此,仅就功能而言,它们是可以互换的!

So for functionality only they're interchangeable!

(不要忘记,type="submit" 是 button 的默认设置,所以不要关闭它!)

(Don't forget, type="submit" is the default with button, so leave it off!)

更多推荐

输入类型=“提交"VS 按钮标签它们可以互换吗?

本文发布于:2023-08-01 18:45:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1270752.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:按钮   类型   标签   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!