jquery提交表单中断 [英] Jquery submit form broken

查看:71
本文介绍了jquery提交表单中断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



I tried stop form refreshing the page but it refreshes page every time i submit the form.

<script>
$("#myforms").submit(function() { 

   return false; 
});
</script>

<form action="" method="post" id="myforms">
      <input id="search123" style="text-align:center" type="text" value="Enter Search..." />
    </form>

更新:

Update:

$(document).ready(function() {
    $("#myforms").submit(function() {
              runSearch123();
              return false;
        });
});

同样的问题

Still same problem

推荐答案

您需要将代码放入jQuery 准备好的处理程序中。

You need to put your code in the jQuery ready handler.

<script>
$(function(){
  $("#myforms").submit(function() {
              return false;
        });
});
</script>

这篇关于jquery提交表单中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆