用jQuery访问下一页

时间:2012-05-16 21:52:19

标签: jquery

我想从键盘点击下一步按钮(右箭头>)进入下一步。 我怎样才能做到这一点? 我找到了一个解决方案,但在成功达到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

1 个答案:

答案 0 :(得分:0)

尝试:

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