js/jQuery的小方法

来源:互联网 发布:mac模拟人生2中文 编辑:程序博客网 时间:2024/05/21 00:01

获取当前日期是当年中的第几周

function getCurrentWeek() {

var totalDays = 0;
var now = new Date();
var years = now.getYear(); if (years < 1000) years += 1900;
var days = new Array(12);
days[0] = 31;
days[2] = 31;
days[3] = 30;
days[4] = 31;
days[5] = 30;
days[6] = 31;
days[7] = 31;
days[8] = 30;
days[9] = 31;
days[10] = 30;
days[11] = 31;


//判断是否为闰年,针对2月的天数进行计算
if (Math.round(now.getYear() / 4) == now.getYear() / 4) {
days[1] = 29
} else {
days[1] = 28
}


if (now.getMonth() == 0) {
totalDays = totalDays + now.getDate();
} else {
var curMonth = now.getMonth();
for (var count = 1; count <= curMonth; count++) {
totalDays = totalDays + days[count - 1];
}
totalDays = totalDays + now.getDate();
}
//得到第几周
var currentWeek = Math.round(totalDays / 7);
alert("当前是第:"+week +" 周");
return currentWeek;

}

//判断当前日期为当年第几周
var getYearWeek = function (a, b, c) {
    var date1 = new Date(a, parseInt(b) - 1, c), date2 = new Date(a, 0, 1),
        d = Math.round((date1.valueOf() - date2.valueOf()) / 86400000);
    return Math.ceil((d + ((date2.getDay() + 1) - 1)) / 7);
};

手机下滑到底端,然后执行代码

<!--向下翻页-->
$(window).scroll(function(){
var windowHeight = parseFloat($(window).height());
var scrollHeight = parseFloat($(window).scrollTop());
var totalheight = windowHeight + scrollHeight;
//$(".content").css("height",totalheight);
if ($(document).height() <= totalheight) {
if (flag) {
currentPage = currentPage + 1;
$("#page_tag_load").show();
flag = false;
setTimeout('getSalePlanList('+ currentPage + ','+ findtype + ')', 1000);
}
}
});

原创粉丝点击