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

actionscript 3 - TweenLite does not work with object -

php - How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader? -

c# - Global Variables vs. ASP.NET Session State -