1
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script src="js/jquery-1.11.2.js"></script>
</head>
<body>
<form id="form1" action="http://www.baidu.com/s">
<input type="text" name="wd" value="" />
<input type="button" value="button按钮" id="btn"/>
<input type="submit" value="submit按钮" id="sub" />
</form>
</body>
</html>
<script type="text/javascript">
/*
//第一种:直接点击submit按钮提交
//第二种提交表单的方式: 点击button按钮后,直接将form表单提交了
window.onload = function () {
document.getElementById("btn").onclick = function () {
document.getElementById("form1").submit();
}
}
//第三种;通过点击button按钮,模拟点击submit按钮
window.onload = function () {
document.getElementById("btn").onclick = function () {
document.getElementById("sub").click();
}
}
*/
//第四种:用Jquery来实现
$("#btn").click(function () {
$("#sub").trigger("click");
})
</script>