是否有更简洁的方法来编写此脚本?

时间:2012-09-10 14:16:53

标签: jquery syntax

几周前,我问过以下问题: simple jquery slideshow script - Is there something wrong with my jquery syntax?

现在我想通过在屏幕上调整容器高度大小来进一步调整幻灯片脚本。

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

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'});
});

});

0 个答案:

没有答案
相关问题