在html5里面,表单元素可以放在表单之外,并通过form属性和表单关联
示例代码如下
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<form action="do.php" method="get" id="a-form">
<input type="hidden" name="from" value="3">
<input type="hidden" name="to" value="2">
<button form="b-form">上一步</button>
<button>下一步</button>
</form>
<form action="do.php" method="get" id="b-form">
<input type="hidden" name="from" value="3">
<input type="hidden" name="to" value="4">
</form>
</body>
</html>
上文中的上一步按钮属于b-form