HTML Input box to fire off some Javascript when the enter key is pressed
Just some simple jQuery code to wire up the 'enter' key on a textbox, which then does some javascript (like an AJAX call to a server).
<input type="text" id="textbox-query" />
$('#textbox-query').keypress(function (e) {
if (e.which == 13) {
doSomething(..);
return false;
}
return true;
});
Written by Pure Krome
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#