在 jquery 中不使用插件创建滑块

问题描述

我不能做这个滑块(在 jquery) 滑块的工作原理: 当它旁边的箭头被按下时它应该工作 2.如果按下底部分页幻灯片ID在顶部),它应该可以工作 3.滑块应该自动工作

滑块视图位于此站点上:

解决方法

<ul>
  <li><img src="image1.jpg" /></li>
  <li><img src="image2.jpg" /></li>
  <li><img src="image3.jpg" /></li>
  <li><img src="image4.jpg" /></li>
  <li><img src="image6.jpg" /></li>
</ul>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
$(window).load (function() {
    var theImage = $('ul li img');
    var theWidth = theImage.width()
    //wrap into mother div
    $('ul').wrap('<div id="mother" />');
    //assign height width and overflow hidden to mother
    $('#mother').css({
        width: function() {
        return theWidth;
      },height: function() {
        return theImage.height();
      },position: 'relative',overflow: 'hidden'
    });
        //get total of image sizes and set as width for ul
    var totalWidth = theImage.length * theWidth;
    $('ul').css({
        width: function(){
        return totalWidth;
    }
    });

});//doc ready

</script>