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

jquery implements keyboard left and right page turning effects_jquery

WBOY
Release: 2016-05-16 16:01:27
Original
1259 people have browsed it

jquery keyboard turns pages left and right, jquery keyboard direction keys page turning function, when there is no previous or next article, there will be no response when pressing the keyboard to avoid wrong jumps.

HTML code

<p>上一篇:<a id='pre' href='http://www.daimajiayuan.com/sitejs-17294-1.html'>一款随滚动条下滑左右渐入的页面布局</a> </p> 
<p>下一篇:<a id='next' href='http://www.daimajiayuan.com/sitejs-18339-1.html'>点击复选框添加或删除value值到input输入框中</a> </p> 
Copy after login

jquery code

$(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; 
    
  }); 
 }); 
Copy after login

The above is the entire content of this article, I hope you all like it.

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!