lundi 2 février 2015

how do i trigger search with the enter key


i need to trigger search with the enter key but its not working, this is the code i used. any help will be appreciated.



$('#header input[name=\'search\']').bind('click', function(e) {

if (e.keyCode == 13) {

url = $('base').attr('href') + 'index.php?route=product/search';

var search = $('input[name=\'search\']').attr('value');

if (search) {
url += '&search=' + encodeURIComponent(search);
}

location = url;
}
});




Aucun commentaire:

Enregistrer un commentaire