Capture enter event and redirect using jquery -


i have functionality on home page of site user enters dish name , presses enter, enter event should captured , should redirect listings page along dish name querystring.

i'm using below code, works second time when click enter.

 $(document).ready(function () {             $(document).keypress(function (e) {                 if (e.which == 13) {                     // enter pressed                     var searchkeyword = $("#searchtextbox").val();                     window.location.href = "/listings.aspx?k=" + searchkeyword;                 }             });         });  

you can see functionality @ http://khanawal.com/home.aspx appreciated.

it appears work long search box isn't selected. try binding both.

$(document).ready(function () {         function handleenter(e) {             if (e.which == 13) {                 // enter pressed                 var searchkeyword = $("#searchtextbox").val();                 window.location.href = "/listings.aspx?k=" + searchkeyword;             }         }          $(document).keypress(handleenter);         $("#searchtextbox").keypress(handleenter);  });  

if doesn't fix it, there's problem elsewhere in code. search stoppropagation in code.


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -