欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery禁止回車觸發(fā)表單提交

 更新時(shí)間:2014年12月12日 11:45:58   投稿:hebedich  
這篇文章主要介紹了jquery實(shí)現(xiàn)的禁止回車觸發(fā)表單提交的方法,非常的使用,這里推薦給大家。

復(fù)制代碼 代碼如下:

<form class="form-inline definewidth m20" action="/" method="get"> 
            <input type="text" name="title" id="title"class="abc" value="">&nbsp;&nbsp; 
            <button type="submit" class="btn" style="margin-right:20px">查詢</button>
            <select name="school_type" id="school_type">
</form>
<td style="width:90px; height:24px; text-align:center"><input   type="text" name="test" value="" class="a"></td>

test文本框的回車事件會(huì)觸發(fā)上面表單的提交,這是瀏覽器的默認(rèn)行為,要禁止自動(dòng)提交,在文本框里取消默認(rèn)事件。

復(fù)制代碼 代碼如下:

$('.a').keypress(function(e){
            if(e.keyCode==13){
                e.preventDefault();
            }

測(cè)試過IE10 FF29正常

相關(guān)文章

最新評(píng)論