Jquery implements the special page turning effect on the left and right of the keyboard

Source: Internet
Author: User

Jquery implements the special page turning effect on the left and right of the keyboard

JQuery implements the code for turning pages of the left and right arrow keys on the keyboard on the webpage. We often see this effect in many novel websites, which can improve the user experience of the website and facilitate visitor paging, thus greatly improving the PV of the website.

 

 

The left and right pages of the jquery keyboard are displayed. When there is no previous or next page, pressing the keyboard does not respond, avoiding incorrect jumps.

HTML code

?

1

2

<P> previous article: <a id = 'pre' href = 'HTTP: // www.daimajiayuan.com/sitejs-17294-1.html'> a page layout that fades around with the scroll bar </a> </p>

<P> next article: <a id = 'Next' href = 'HTTP: // www.daimajiayuan.com/sitejs-18339-1.html'> click the check box to add or delete value values to the input box. </a> </p>

Jquery code

?

1

2

3

4

5

6

7

8

9

$ (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;

 

});

});

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.