Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.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
jQuery图像向上滑动而不是向右滑动_Jquery_Html - Fatal编程技术网

jQuery图像向上滑动而不是向右滑动

jQuery图像向上滑动而不是向右滑动,jquery,html,Jquery,Html,基本上,我的代码是在我希望图像向右滑动时使其向上滑动。怎么了 HTML <div id="wrapper"> <div id="header"> </div> </div> 下面是代码:您需要增加值 function scrollBg(){ //Go to next pixel row. current += step; //increment instead of decrement //If at

基本上,我的代码是在我希望图像向右滑动时使其向上滑动。怎么了

HTML

<div id="wrapper">
    <div id="header">
    </div>
</div>

下面是代码:

您需要增加值

function scrollBg(){

    //Go to next pixel row.
    current += step; //increment instead of decrement

    //If at the end of the image, then go to the top.
    if (current == restartPosition){
        current = 0;
    }

    //Set the CSS of the header.
    $('#header').css("background-position",current +"px 0"); // parameters are right top not top right



}

演示:

更新:我找到了答案

$('#header').css("background-position","0 "+current+"px");
我将0更改为1,它将其修复。这纯粹是运气使然,但为什么要这样做呢

$('#header').css("background-position","0 "+current+"px");