Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.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_Slider_Jquery Animate - Fatal编程技术网

通过JavaScript向左滑动

通过JavaScript向左滑动,javascript,jquery,slider,jquery-animate,Javascript,Jquery,Slider,Jquery Animate,我有这样的结构: <div style="background-color:#FFF;height:49px;border-top:1px solid #ef4723;clear:both"> <div id="marka-slider" class="row"> <ul> <?php if (($references = Reference::getAll())) : foreach ($refere

我有这样的结构:

<div style="background-color:#FFF;height:49px;border-top:1px solid #ef4723;clear:both">
  <div id="marka-slider" class="row">
    <ul>
      <?php if (($references = Reference::getAll())) :
              foreach ($references as $r) :
      ?>
        <li>
          <img src="<?php echo Reference::getUploadPath() . '/' . $r->mediapath; ?>"
               alt="<?php echo $r->title; ?>" title="<?php echo $r->title; ?>"/>
               <!-- <?php CVarDumper::dump(array('ref: ' => $r->attributes), 5, 1); ?>  -->
        </li>
      <?php endforeach; ?>
      <?php endif; ?>
    </ul>

  </div>
</div>
但它不起作用。当我通过Firebug检查时,它不会给出错误。我怎样才能解决它


您正在为
li
标记的背景图像设置动画,而图像位于
img
标记的
li
内。

您是否尝试滑动图像???@Charlie是的。我尝试了。请给我定义div中使用的类行。您的bgcroll函数没有右括号您的演示中没有包含CSS
var slider;
$(document).ready(function () {
  slider = $('#marka-slider ul li');

  setTimeout(function() {
    bgscroll('right');
  }, 1000);
});

function bgscroll(direction) {
  var sign;
    if (direction === 'left') {
      slider.stop().animate({'background-position': '+=10000'}, 200000, 'linear', bgscroll);
    } else {
      slider.stop().animate({'background-position': '-=10000'}, 200000, 'linear', bgscroll);
    }