消除客户端缓存
<meta http-equiv="pragma" content="no-cache" />
jQuery.validate 检查单个控件
validator.element(控件元素)
单例和私有成员封装实例
var singleton = function () {
var privateVariable;
function privateFunction(x) {
...privateVariable...
}
return {
firstMethod: function (a, b) {
...privateVariable...
},
secondMethod: function (c) {
...privateFunction()...
}
};
}();
js或者jquery无限滚动实现原理:
$(window).bind("scroll",function(){
// 然后判断窗口的滚动条是否接近页面底部,这里的20可以自定义
if( $(document).scrollTop() + $(window).height() > $(document).height() - 20 ){
$.ajax({
//ajax代码,异步载入数据
//一般的会callback,将数据填入固定的选择器中
})
}
})
给窗口绑定上一个scroll事件,即滚动的时候判断,$(document).scrollTop() 滚动条滚动的高度+$(window).height()窗口的高度>$(document).height()页面的整体高度-20个像素之所以减去20个像素是在距离底部还有20个像素的时候预先载入,可以设置为0,即滚动到底部才载入。