This article will share with you the special effect of using jQuery to press the arrow key of the keyboard to flip pages. the code is very simple and the function is very practical. we recommend it to you and hope you will like it.
1. jQuery code:
The code is as follows:
$ (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 code:
The code is as follows:
Previous:
A page layout that fades in along with the scroll bar
Next Article:
Click the check box to add or delete the value to the input box.
Remember to introduce the jQuery file. well, there is not much nonsense here. I hope this article will help you learn jQuery.