type='submit' 提交按钮,默认点击后触发的是表单的submit事件,提交其所属的表单
type='button' 一般按钮,默认点击后触发的是click事件,具体点击后进行什么样的操作,需要自己通过js代码来实现
思路:本题要想实现用javascript做出重置效果需要用到JavaScript实现重置表单(reset)的方法。
例子:
<form id="form1"><input type="text" id="name"/>
<input type="button" value="这个用JavaScript清除" onclick="document.getElementById('form1').reset()"/>
<input type="reset" value="这个是Form清除" />//reset()重置
</form>
<html><head>
<title></title>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#change").click(function(){
$("*").css({"margin":"0","padding":"0"})
})
})
</script>
</head>
<body>
<div style="width:500px margin-left:20px padding:50px height:300px background-color:red"></div>
<div style="width:500px margin-left:50px padding:40px height:300px background-color:blue"></div>
<input type="button" value="change" id="change">
</body>
</html>