Tôi có hộp tìm kiếm trên trang web của mình. Hiện tại, người dùng phải nhấp vào nút gửi bên cạnh hộp để tìm kiếm qua bài đăng của jquery. Tôi muốn cho phép người dùng cũng nhấn enter để tìm kiếm. Tôi có thể làm cái này như thế nào?Kích hoạt sự kiện trên `click` và` enter`
jQuery:
$('document').ready(function(){
$('#searchButton').click(function(){
var search = $('#usersSearch').val();
$.post('../searchusers.php',{search: search},function(response){
$('#userSearchResultsTable').html(response);
});
});
});
HTML:
<input type='text' id='usersSearch' /><input type='button' id='searchButton' value='search' />
Xem tại đây: http://stackoverflow.com/questions/699065/submitting-a-form-on-enter-with-jquery – mowwwalker
Yup, chức năng tìm kiếm rất hữu ích ... – elclanrs