Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/478.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 凯丹广场箭头控制_Javascript_Jquery_Galleria - Fatal编程技术网

Javascript 凯丹广场箭头控制

Javascript 凯丹广场箭头控制,javascript,jquery,galleria,Javascript,Jquery,Galleria,我和凯丹有点问题。 以下代码: <script type="text/javascript"> $(document).keypress(function(e) { switch(e.keyCode) { case 37: //press left arrow $.galleria.prev(); break; case 39

我和凯丹有点问题。 以下代码:

<script type="text/javascript">
    $(document).keypress(function(e)
      {
        switch(e.keyCode)
        {
          case 37: //press left arrow  
                $.galleria.prev();
                break;
          case 39: //press right arrow
                $.galleria.next();
                break;  
        }
      });


</script>

$(文档)。按键(功能(e)
{
开关(如钥匙代码)
{
案例37://按左箭头
$.galleria.prev();
打破
案例39://按向右箭头
$.galleria.next();
打破
}
});
不起作用,上面说:
$。galleria未定义
如果我改用
Galleria.prev()
Galleria.next()
然后它说:
Galleria.next不是一个函数
,与前面的函数相同

我希望有经验的人能帮助我

提前感谢,,
Adam

galleria似乎有一个附加键盘方法,但我无法让它起作用。但是,通过使用上面的代码,我成功地获得了箭头控件。试试这个:

<script>
//start galleria
Galleria.loadTheme('galleria.classic.js');
$('#galleria').galleria();

//obtain galleria instance - this might be the step you are missing
var gallery = Galleria.get(0);

//essentially what you had above
document.onkeyup = KeyCheck;       
function KeyCheck(e) {
    var KeyID = (window.event) ? event.keyCode : e.keyCode;
    switch(KeyID) {
        case 37: //press left arrow 
            gallery.prev();
            break;
        case 39: //press right arrow
            gallery.next();
            break;
    }
}
</script>

//启动画廊
Galleria.loadTheme('Galleria.classic.js');
$(“#galleria”).galleria();
//获取galleria实例-这可能是您缺少的步骤
var gallery=Galleria.get(0);
//基本上就是你上面所说的
document.onkeyup=KeyCheck;
功能键检查(e){
var-KeyID=(window.event)?event.keyCode:e.keyCode;
开关(KeyID){
案例37://按左箭头
画廊,上一页();
打破
案例39://按向右箭头
画廊。下一页();
打破
}
}

您是否可以在没有此功能的情况下使用Galleria,并在页面上查看hello world以测试您是否已将所有内容设置正确?此脚本是否在包含Galleria插件之前出现在页面中?+1。。。在试图理解为什么人们一直建议
$.galleria.next()
会起作用时找到了这个答案,但对我来说并没有……这确实起作用。有人知道上下文的区别是什么吗?