将键盘绑定到左/右导航

编程入门 行业动态 更新时间:2024-10-26 11:16:47
本文介绍了将键盘绑定到左/右导航的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是一名摄影师,有一个网站,我无法编辑'模板'结构,但可以上传javascript / css等。

I am a photographer and have a website where I am unable to edit the 'template' structure but can upload javascript/css etc.

我想接下来绑定/ prev键盘右/左导航。

I want to bind next/prev navigation to keyboard right/left.

链接结构为:

<div class="image_navigation"> <h4>Image Navigation</h4> <ul> <li class="index"><a href="LINKURL">Index</a></li> <li class="previous"><a href="LINKURL">Previous</a></li> <li class="next"><a href="LINKURL">Next</a></li> </ul> </div>

我提到 this 并设法创建它。

I referred to this and managed to create this.

$(function() {$(document).keyup(function(e) { switch(e.keyCode) { case 37 : window.location = $('li.prev').attr('href'); break; case 39 : window.location = $('li.next').attr('href'); break; }});});

这是我被困的地方。它不起作用,因为它假定我正在引用一个href标签但引用包含它的li。

This is where I am stuck. It does not work because it assumes the I am refereing to a href tag but am refering to the li that contains it.

任何想法都会非常感激!

Any ideas would be much appreciated!

推荐答案

window.location = $('li.next a').attr('href');

更多推荐

将键盘绑定到左/右导航

本文发布于:2023-11-23 03:53:40,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619993.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:绑定   键盘

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!