温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

HTML5中form新增的属性是什么

发布时间:2021-02-26 09:42:13 来源:亿速云 阅读:185 作者:清风 栏目:web开发

这篇文章主要为大家展示了HTML5中form新增的属性是什么,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带大家一起来研究并学习一下“HTML5中form新增的属性是什么”这篇文章吧。

html是什么

html的全称为超文本标记语言,它是一种标记语言,包含了一系列标签.通过这些标签可以将网络上的文档格式统一,使分散的Internet资源连接为一个逻辑整体,html文本是由html命令组成的描述性文本,html命令可以说明文字,图形、动画、声音、表格、链接等,主要和css+js配合使用并构建优雅的前端网页。

1.HTML 5 <input> formaction 属性

定义和用法

formaction 属性规定当提交表单时,向何处发送表单数据。

注意内容:

1.formaction 属性规定当表单提交时处理输入控件的文件的 URL。

2.formaction 属性覆盖 <form> 元素的 action 属性。

注释:formaction 属性适用于 type="submit" 和 type="image"。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>formaction</title>
</head>
<body>
<form id="testform">
    <input type="submit" name="s1" value="v1" formaction="http://localhost:8080/index01/Test01.jsp">提交到http://localhost:8080/index01/Test01.jsp
    <input type="submit" name="s2" value="v2" formaction="http://localhost:8080/index01/Test02.jsp">提交到http://localhost:8080/index01/Test02.jsp
    <input type="submit" name="s3" value="v3" formaction="http://localhost:8080/index01/Test03.jsp">提交到http://localhost:8080/index01/Test03.jsp
</form>
</body>
</html>

2.HTML 5 <button> formmethod 属性

定义和用法

formmethod 属性覆盖 form 元素的 method 属性。

可以通过以下方式发送 form-data :

  • 以 URL 变量 (使用 method="get") 的形式来发送

  • 以 HTTP post (使用 method="post") 的形式来发送

该属性与 type="submit" 配合使用。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <form id="testform">
        <input type="submit" name="s1" value="v1" formmethod="post" formaction="http://localhost:8080/index01/Test01.jsp">http://localhost:8080/index01/Test01.jsp
        <input type="submit" name="s2" value="v2" formmethod="get" formaction="http://localhost:8080/index01/Test02.jsp">http://localhost:8080/index01/Test02.jsp
        <input type="submit" name="s1" value="v1" formmethod="post" formaction="http://localhost:8080/index01/Test03.jsp">http://localhost:8080/index01/Test03.jsp
    </form>
</body>
</html>

<!DOCTYPE HTML>
<html>
<body>
<form action="/example/html5/demo_form.asp" method="get">
  姓:<input type="text" name="lname" /><br />
  名:<input type="text" name="fname" /><br />
<button type="submit" >提交</button>
<button type="submit" formmethod="post" formaction="/example/html5/demo_post.asp">使用 POST 来提交</button>
</form>
</body>
</html>

3HTML 5 <input> autofocus 属性

定义和用法

autofocus 属性规定当页面加载时 input 元素应该自动获得焦点。

如果使用该属性,则 input 元素会获得焦点。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<form>
    <input type="text">
    <input type="text" autofocus>
</form>
</body>
</html>

以上就是关于“HTML5中form新增的属性是什么”的内容,如果改文章对你有所帮助并觉得写得不错,劳请分享给你的好友一起学习新知识,若想了解更多相关知识内容,请多多关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI