检测浏览器对w3c dom支持:
if(document.createElement && document.getElementsByTagName){
//code
}
添加事件处理程序:
function addEventSimple(obj,evt,fn){
if(obj.addEventListener)//W3C
obj.addEventListener(evt,fn,false);
else if(obj.attachEvent)//microsoft
obj.attachEvent('on'+evt,fn);
}
自执行函数:
-----------------
(function(){
var a = "aaaaaa";
alert(a);
})();
--------------------
(function(){
var a = "aaaaaa";
alert(a);
}());
-----------------//参数name
(function(name_aa,$){
var a = name_aa;
alert(a);
}(name,jQuery));
闭包:
javascript的 getter和setter