Home  >  Article  >  Web Front-end  >  jQuery实现按键盘方向键翻页特效_jquery

jQuery实现按键盘方向键翻页特效_jquery

WBOY
WBOYOriginal
2016-05-16 16:09:001142browse

1.jQuery代码

复制代码 代码如下:

$(document).ready(function(){
    var prevpage=$("#pre").attr("href");
    var nextpage=$("#next").attr("href");
    $("body").keydown(function(event){
      if(event.keyCode==37 && prevpage!=undefined) location=prevpage;
      if(event.keyCode==39 && nextpage!=undefined) location=nextpage;
    });
 });

2.Html代码:

复制代码 代码如下:

记得要引入jQuery文件哦,好了这里就不多废话了,希望本文能够对大家学习jQuery有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn