Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 16:09:00
Original
1131 people have browsed it

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有所帮助。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!