0.语法
var StaticClazz = { //static property and method
name : "张三",
show : function(){
alert(this.name);
}
//this.show = function(){}
}
StaticClazz.show(); // 静态类不需要实例化
function Emp(){
this.name = "李四"; //public property
age = 10; //private property
}
Emp.prototype = {
sex : '男',
show : function(){
alert(this.name + " " +age);
}
}
Emp.prototype.sex = "女";
var emp = new Emp;
alert("name: " + emp.name + " age: " + emp.age + " sex: " + emp.sex);
emp.show();
Emp.show3 = function(){
alert("show3");
}
Emp.show3();
//判断为空
function Utils(){
}
Utils.isEmpty = function(v, allowBlank)
{
return v === null || v === undefined
|| (!allowBlank ? v.trim().length === 0 : false);
};
1. 在火狐下获得year需要+1900
var x=navigator.appName;///判断浏览器的名称
var date=new Date();
var thisYear=date.getYear();
if(x=='Netscape'){ //在火狐下获得year需要+1900
thisYear+=1900;
}
2. 点击其他地方隐藏弹出层
jQuery(".showDivId").click(function(e){e.stopPropagation();}) //屏蔽其他事件
jQuery("body").click(function(){
jQuery(".showDivId").remove();
});
3.遍历
for ( var key in field.options) {}
4.获得body大小document.body.clientWidth
5.迭代
for( var name in jsonObj) {
}
6.点击区域判断
$(document).click(function(event){
if ($(event.target).closest("#dropdown").length == 0){
//隐藏对象操作
}
});

被折叠的 条评论
为什么被折叠?



