jquery - Trigger function on Enter keypress -


i've simple search function want trigger on enter key press, though function executes form posted.

<script> function search() {  ... }  $(document).ready(function() {   $("#text").keypress(function (e) { if (e.which==13)   search();  }); });  <body> <form id="searchform" name="searchform">  <input size="40" id="text" type="text" name="text" class="input" /> </form> </body> 

bind function submit event , prevent default:

$('form').submit(function(ev){     ev.preventdefault();     /* code here */ }); 

Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -