我有很多在这信息的页面,如果用户点击了一个链接和浏览器的搜索栏上弹出,因为它会如果他们按下Ctrl键+˚F这将是很好。我可以查询数据库,因为信息来自那里,但我不想重新加载链接点击页面。是否有可能使用Jquery模拟Ctrl + F组合键?
6
A
回答
6
2
有一些插件,让你这样做,例如:https://github.com/jeresig/jquery.hotkeys
2
我知道这个职位是旧的,但我想我解决了这个使用jquery:
//i am assuming you are searching through a table...
//search input field listening for key pressed
$('.search_input').keyup(function (e) {
//listening if the key pressed is the enter button
if (e.which === 13) {
//inserting the value of textfield content, you can add if statement to check if the field is null or empty
var search_param = $(this).val();
//value of field stored into a variable
$('td').removeAttr('class');
//remove all classes attributed to a td AND search all td to find the one that march the search parameter
if ($('td:contains("' + search_param + '")').html() !== undefined) {
//if there is any td that has that record... then check for the closest tr and add a class with item_found as value
$('td:contains("' + search_param + '")').closest('tr').attr('class', 'item_found');
//add some highlight to it.
$('td:contains("' + search_param + '")').closest('tr').css({background:'yellow',color:black});
//then scroll to the item
$(window).scrollTop($('.item_found').first().offset().top);
} else {
//if item is not found display no result found
alert("Sorry no result found")
}
}
});
相关问题
- 1. 如何模拟Ctrl-S组合键?
- 2. linux组合键[Ctrl +,]和[Ctrl +。]被禁用?
- 3. 是否有可能模拟jqGrid中的导航键按下?
- 4. 在页面加载时,发送/模拟组合键[CTRL + L]
- 5. 是否有可能使用Moq在C#中模拟模拟的“类型名称”?
- 6. 我可以在javascript或jquery中模拟按键(CTRL + F1)吗?
- 7. 是否有可能仅使用响应变量来拟合线性模型?
- 8. 模拟击键组合
- 9. 是否有可能使用NServiceBus和Azure WITHOUT Azure模拟器?
- 10. 如何模拟使用C#的功能组合键?
- 11. 是否有可能在JavaScript只是用Ctrl + C复制图像
- 12. 使用jQuery模拟按键
- 13. 使用jQuery模拟按键
- 14. 是否有可能使用jQuery
- 15. 是否有可能使用jQuery,Javascript,
- 16. 是否有可能使用extract()和数组键名“some.key”?
- 17. 是否有可能在F#中结合多个属性?
- 18. 是否有可能(模拟?)AUTOINCREMENT对Sqlite中的compound-PK?
- 19. 是否有可能组合框的jQuery自动通过输入
- 20. 是否有可能使keyCode等于键?
- 21. 每次单击鼠标左键时,是否有办法模拟Ctrl按?
- 22. 是否有F#Monogame模板?
- 23. 是否可以在页面中禁用Ctrl + F查找?
- 24. 是否有可能在JSF 2中使用复合组件的模板?
- 25. 是否有可能在f#中使用CallerMemberNameAttribute?
- 26. jquery模仿按键“ctrl +”
- 27. 是否有可能为F#元组创建扩展方法
- 28. 是否可以使用Dev Express TdxBarSubItems模拟TMenuBreak功能?
- 29. 如何用C++模拟按Ctrl + C组合在Windows
- 30. 是否按下'Ctrl'键?
http://stackoverflow.com/questions/832059/definitive-way-to-trigger-keypress-events-with-jquery – Neal
[通过网站上的按钮使用浏览器搜索(Ctrl + F)?]可能的重复(HTT p://stackoverflow.com/questions/8080217/use-browser-search-ctrlf-through-a-button-in-website) – Sheepy