js/jQuery的小方法
2017-09-30 11:01
148 查看
获取当前日期是当年中的第几周
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);
}
}
});
相关文章推荐
- 前端那些事之原生js实现jquery常用方法
- 使用JS/Jquery获得父窗口的几个方法(笔记)
- jquery ajaxFileUpload.js插件支持多文件上传的方法
- jQ基础篇--jQuery与JS中的map()方法
- 关于js不能再jquery的ready方法下运行
- 比较不错的JS/JQuery显示或隐藏文本的方法
- jquery与js函数冲突的两种解决方法
- 结合jQuery的unload方法实现JS退出页面弹出对话框
- Jquery 模板插件 jquery.tmpl.js 的使用方法(1):基本语法,绑定,each循环,ajax获取json数据
- 三种动态加载js的jquery实例代码另附去除js方法
- js与jquery获取父元素,删除子元素的两种不同方法
- js--下拉列表选中(js和jquery两种方法 )
- 解决同一页面jQuery多个版本或和其他js库冲突方法
- js监听键盘事件的方法—原生和jquery的区别
- 简单选项卡 js和jquery制作方法分享
- Bootstrap框架使用iframe及jQuery中load方法导致js失效问题
- 解决jQuery多个版本,与其他js库冲突方法
- JS不能跨域借助jquery获取IP地址的方法
- Jquery JS 正确的比较两个数字大小的方法