jQuery绑定键盘事件
来源:互联网 发布:python 调用caffe模型 编辑:程序博客网 时间:2024/05/29 08:36
作者:lina791211-----感谢作者!!
雪影工作室版权所有,转载请注明【http://blog.csdn.net/lina791211】
1、前言
Jquery绑定各种键盘输入事件。
键值获取:http://blog.csdn.net/lina791211/article/details/36025571
2、绑定回车键
input输入框绑定回车响应(提交数据)
<span> <pre name="code" class="html" style="font-size: 18px; line-height: 26px;"><span style="font-family: Arial;"></span><pre name="code" class="html" style="font-size: 18px; line-height: 26px;"><span style="font-family: Arial;"><input class="typeahead" type="text" id="textfield" placeholder="请输入搜索关键词" style="margin-top: 10px;width: 410px"></span></span>
<span><button type="button" class="btn_search btn_search_primary" id="simpleSearchButton" style="top:0;margin-top: -3px">搜 索</button></span>
/*监听输入框的回车操作*/ $('#keyword').bind('keypress',function(event){ if(event.keyCode == "13") $('#simpleSearchButton').click(); });
3、button绑定click事件并提交数据
$('#simpleSearchButton').click(function(){var _k = $('#textfield').val();var url = '';if(_k==null || _k==""){//url = encodeURI('<%=path%>/');return;}else{url = encodeURI('<%=path%>/search.jsp?keyword=' + _k);}url = encodeURI(url);window.open(url,'_self');});
4、页面绑定键盘左键、右键进行翻页
<div id="search_paging"><div class="gigantic pagination"> <a href="#" class="first" data-action="first">«</a> <a href="#" class="previous" data-action="previous">‹</a> <input class='current' id='c_page' type="text" value="Page 10 of 10"/> <a href="#" class="next" data-action="next">›</a> <a href="#" class="last" data-action="last">»</a></div></div>
/*监听键盘上左右键的点击*/$(document).keydown(function(event){ <span style="white-space:pre"></span>if(event.which == "37") {$(".previous").click(); return;} <span style="white-space:pre"></span>if(event.which == "39") {$(".next").click(); return;}});
阅读全文
0 0
- jQuery绑定键盘事件
- jQuery绑定键盘事件
- jQuery绑定键盘事件
- jQuery绑定键盘压下抬起事件
- jquery快捷动态绑定键盘事件操作函数
- 键盘绑定事件
- jQuery——事件篇( 鼠标、表单、键盘、事件绑定和解绑、事件对象、自定义事件)
- jQuery事件-键盘事件
- jQuery之鼠标事件 、表单事件、键盘事件、事件的绑定和解绑、事件对象的使用、自定义事件
- js 绑定键盘鼠标事件
- EditText绑定键盘监听事件
- jquery 键盘事件捕捉
- jquery键盘事件
- jquery键盘事件
- jquery 键盘事件
- JQuery添加键盘事件
- jquery键盘点击事件
- jquery键盘事件
- 静态链接库和动态链接库
- 机房效果图制作|简易制作教程赘述
- Spark性能优化——数据倾斜
- 算法作业 NP-complete problems 8.22
- [js] ES6 函数
- jQuery绑定键盘事件
- git 删除远程分支 创建远程分支 (干货)
- 随笔分类
- mysql中engine=innodb和engine=myisam区别
- 原生js和jquery框架下绑定事件的方法
- 287. Find the Duplicate Number找环的起点
- 如何下载Youtobe视频和字幕(可下载自动翻译的中文字幕)
- 蚂蚁爬杆问题--面向对象,建模
- 栈和队列上手题 HDU1702 HDU1022 HDU1237 HDU3328 HDU1873 HDU1509 HDU1870 HDU1387 题解