form提交不刷新页面

在函数里面加入return false即可

 1 <html>
 2     <head><head/>
 3     <script>
 4 function change() {
 5     p.innerText = f.a.value;
 6     return false;
 7 }
 8     </script>
 9     <body>
10     <p id="p">1</p>
11     <form name="f" id="f" onSubmit="return change();">
12         <input name="a" type="text" value="kk"/>
13         <input type="submit" value="submit"/>
14     </form>
15     </body>
16 </html>

 

posted @ 2017-01-09 16:13  Netop  阅读(4519)  评论(0编辑  收藏  举报