var i = 0;
clock();
function clock(){
var now,hours,minutes,seconds,time;
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
time = (hours >= 12) ? "A.M. ":"P.M. ";
time += ((hours > 12) ? hours - 12 : hours) + " H";
time += ((minutes < 10) ? " 0" : " ") + minutes + " M";
time += ((seconds < 10) ? " 0" : " ") + seconds + " S";
$("#gundamTime .clockBox").html(time);
if( seconds % 5 == 0){
i = i % $(".gundamPic ul li").length;
$(".gundamPic ul li").eq(i).fadeTo(1000, 1).css({
opacity:1,
zIndex: 10
}).siblings().fadeTo(2000, 0).css({
opacity:0,
zIndex:9
});
i++;
}
setTimeout(clock,1000);
}
對之前的 clock 做了修改
背景圖片加了淡入淡出效果
2012年2月5日 星期日
2012年2月4日 星期六
jqeury_clock+picbur(jquery)
$(function(){
var i = 0;
clock();
function clock(){
var now,hours,minutes,seconds,time;
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
time = (hours >= 12) ? "A.M. ":"P.M. ";
time += ((hours > 12) ? hours - 12 : hours) + " H";
time += ((minutes < 10) ? " 0" : " ") + minutes + " M";
time += ((seconds < 10) ? " 0" : " ") + seconds + " S";
$("#gundamTime .clockBox").html(time);
if( minutes % 5 == 0){
if(i < $(".gundamPic ul li").length){
i++;
}else{
i=0;
}
$(".gundamPic ul li").eq(i).fadeTo(1000, 1).css('opacity', 1).siblings().fadeTo(2000, 0).css('opacity', 0);
}
setTimeout(clock,1000);
}
});
var i = 0;
clock();
function clock(){
var now,hours,minutes,seconds,time;
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
time = (hours >= 12) ? "A.M. ":"P.M. ";
time += ((hours > 12) ? hours - 12 : hours) + " H";
time += ((minutes < 10) ? " 0" : " ") + minutes + " M";
time += ((seconds < 10) ? " 0" : " ") + seconds + " S";
$("#gundamTime .clockBox").html(time);
if( minutes % 5 == 0){
if(i < $(".gundamPic ul li").length){
i++;
}else{
i=0;
}
$(".gundamPic ul li").eq(i).fadeTo(1000, 1).css('opacity', 1).siblings().fadeTo(2000, 0).css('opacity', 0);
}
setTimeout(clock,1000);
}
});
jquery_setTimeout_clock(Jquery)
function clock(){
var now,hours,minutes,seconds,time;
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
time = (hours >= 12) ? "a.m.":"p.m.";
time += ((hours > 12) ? hours - 12 : hours) + " H";
time += ((minutes < 10) ? " 0" : " ") + minutes + " M";
time += ((seconds < 10) ? " 0" : " ") + seconds + " S";
$("#gundamTime").html(time);
setTimeout(clock,1000);
}
var now,hours,minutes,seconds,time;
now = new Date();
hours = now.getHours();
minutes = now.getMinutes();
seconds = now.getSeconds();
time = (hours >= 12) ? "a.m.":"p.m.";
time += ((hours > 12) ? hours - 12 : hours) + " H";
time += ((minutes < 10) ? " 0" : " ") + minutes + " M";
time += ((seconds < 10) ? " 0" : " ") + seconds + " S";
$("#gundamTime").html(time);
setTimeout(clock,1000);
}
2012年2月3日 星期五
jquery_setTimeout_example(Jquery)
<script type="text/javascript">
$(function(){
var i = -1;
var a = -1;
$('#content #column-left .box .box-content').eq(1).attr("class", 'on1');
$('#content #column-left .box .box-content').eq(1).attr("class", 'on2');
// alert($('.on2 .images div').length);
autoShow();
function autoShow(){
if(i+1<$('.on1 .images div').length){
i++;
}else{
i=0;
}
if(a+1<$('.on2 .images div').length){
a++;
}else{
a=0;
}
$('.on1 .images div').eq(i).show().siblings().hide();
$('.on1 .slidetabs a').eq(i).addClass("current").siblings().removeClass("current");
$('.on2 .images div').eq(a).show().siblings().hide();
$('.on2 .slidetabs a').eq(a).addClass("current").siblings().removeClass("current");
timer = setTimeout(autoShow, 5000);
}
});
</script>
-------------------------------------------------------------------------------------------------------------------------------
Other examples of jquery :
http://www.minwt.com/?p=1138
最主要我知道了 eq() 抓取麼一個相同元素的使用方法,
不會因為每一次都 抓到第一個煩惱。
$(function(){
var i = -1;
var a = -1;
$('#content #column-left .box .box-content').eq(1).attr("class", 'on1');
$('#content #column-left .box .box-content').eq(1).attr("class", 'on2');
// alert($('.on2 .images div').length);
autoShow();
function autoShow(){
if(i+1<$('.on1 .images div').length){
i++;
}else{
i=0;
}
if(a+1<$('.on2 .images div').length){
a++;
}else{
a=0;
}
$('.on1 .images div').eq(i).show().siblings().hide();
$('.on1 .slidetabs a').eq(i).addClass("current").siblings().removeClass("current");
$('.on2 .images div').eq(a).show().siblings().hide();
$('.on2 .slidetabs a').eq(a).addClass("current").siblings().removeClass("current");
timer = setTimeout(autoShow, 5000);
}
});
</script>
-------------------------------------------------------------------------------------------------------------------------------
Other examples of jquery :
http://www.minwt.com/?p=1138
最主要我知道了 eq() 抓取麼一個相同元素的使用方法,
不會因為每一次都 抓到第一個煩惱。
訂閱:
文章 (Atom)