简体   繁体   English

用jQuery访问下一页

[英]visit next page with jQuery

I want to go next by clicking Next button (right arrow >) from keyboard. 我想通过单击键盘上的“下一步”按钮(向右箭头>)继续下一步。 How can I do that? 我怎样才能做到这一点? I found a solution, but failed before succeeding 100%. 我找到了解决方案,但未成功100%成功。

<html>

    <head>
        <script src="jquery-1.4.2.js"></script>
        <script src="jquery.hotkeys.js"></script>
        <script>
            //This page is a result of an autogenerated content made by running test.html with firefox.
            function domo() {
                jQuery(document).bind('keydown', 'right', function (evt) {
                    location.href = $('#previous_page_link').href;
                    //window.location.href = 'http://www.google.com';
                });
            }
            jQuery(document).ready(domo);
        </script>
    </head>

    <body>
        <a id="previous_page_link" href="http://www.google.com">Google</a>
        <a id="next_page_link" href="http://www.yahoo.com">Yahoo</a>
    </body>

</html>

https://github.com/jeresig/jquery.hotkeys https://github.com/jeresig/jquery.hotkeys

try: 尝试:

jQuery(document).ready(function() {
     jQuery(document).bind('keydown', 'right', function () {
          location.href = $('#previous_page_link').attr('href');
       });
   });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM