0

几周前,我问了以下问题: 简单的 jquery 幻灯片脚本 - 我的 jquery 语法有问题吗?

现在,我想通过在屏幕调整大小时更改容器高度来使该幻灯片脚本更进一步。

这就是我到目前为止所拥有的。我只想知道是否有更清洁的方法来做到这一点?

var j$ = jQuery.noConflict();

j$(document).ready(function(){

  j$.fn.slideShow = function (timeOut) {

      var $slidecontainer = this;
      var imgheight =  $slidecontainer.children('img').first().outerHeight();

      $slidecontainer.css({'height': imgheight, 'overflow':'hidden','position':'relative'});
      $slidecontainer.children(':gt(0)').hide();

      setInterval(function () {
          $slidecontainer.children().eq(0).fadeOut(2000).next().fadeIn(2000).addClass('on').nextAll().removeClass('on').end().end().appendTo($slidecontainer);
      }, timeOut || 1000);
  };

  j$(window).load(function () {
     j$('.slideshow').slideShow(6000);
  });

j$(window).resize(function() {
   var imgheight =  j$('.slideshow').children('img').first().outerHeight();
  j$('.slideshow').css({'height': imgheight, 'overflow':'hidden','position':'relative'});
});

});
4

0 回答 0