jquery keyboard left and right page turning effects

  • 2020-06-03 05:44:23
  • OfStack

jquery keyboard page turning left and right, jquery keyboard arrow key page turning function, when there is no one or the next post, press the keyboard will have no response, avoid error jump.

HTML code


<p> on 1 Article: <a id='pre' href='http://www.daimajiayuan.com/sitejs-17294-1.html'>1 A page layout that slides down the scroll bar to the left and right </a> </p> 
<p> Under the 1 Article: <a id='next' href='http://www.daimajiayuan.com/sitejs-18339-1.html'> Click the check box to add or remove value Value to the input In the input box </a> </p> 

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; 
    
  }); 
 }); 

This is the end of this article, I hope you enjoy it.


Related articles: