数週間前、私は次の質問をしました: シンプルな 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'});
});
});