Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javascriptÉè¼ÆÄ£Ê½_µÚ¶þ²¿·Ö_Á´Ê½µ÷ÓÃ

 Á´Ê½µ÷ÓÃÊÇÒ»¸öÓï·¨ÕÐÊý.°üº¬Á½¸ö²¿·Ö:
1.Ò»¸ö´´½¨HTMLÔªËØµÄ¶ÔÏóµÄ¹¤³§
2.¶ÔÕâ¸öHTMLÔªËØÖ´ÐеIJÙ×÷µÄ·½·¨
[¸öÈËÀí½â:½«HTMLÔªËØ°ü×°³É¶ÔÏó,ÔÚ¶ÔÏóÉÏÌí¼Ó·½·¨(ÖØµãÔÚreturn this)]
¹¹ÔìÆ÷
(function(){
//Use a private class
function _$(els){
this.elements = [];
for(var i=0; i<els.length; i++){
var element = els[i];
if(typeof element === "string"){
element = document.getElementById(element);
}
this.elements.push(element);
}
}
//
_$.prototype = {
each : function(fn){
for(var i=0; i<this.elements.length; i++){
fn.call(this,this.elements[i]);
}
return this;
},
setStyle : function(prop,val){
this.each(function(el){
el.style[prop] = val;
});
return this;
},
show : function(){
var that = this;
this.each(function(el){
that.setStyle("display","bloc");
});
return this;
},
addEvent : function(type,fn){
var add = function(el){
if(window.addEventListener){
el.addEventListener(type,fn,false);
}
else if(window.attachEvent){
el.attachEvent("on"+type,fn);
}
}
this.each(function(el){
add(el);
})
return this;
}
};
//the public interface remains the same
window.$ = function(){
return new _$(arguments);
}
})()

ʹÓûص÷´ÓÖ§³ÖÁ´Ê½µ÷Óõķ½·¨»ñÈ¡Êý¾Ý
Á´Ê½µ÷ÓúÜÊʺÏÓÚ¸³ÖµÆ÷·½·¨,µ«¶ÔÓÚȡֵÆ÷·½·¨,Äã¿ÉÄÜ»áÏ£ÍûËüÃÇ·µ»ØÄãÒªµÄÊý¾Ý¶ø²»ÊÇ·µ»Øthis.
window.API2 = window.API2 || function(){
var name = "hell";
this.setName = function(newName){
name = newName;
return this;
};
this.getName = function(callback){
callback.call(this,name);
return this;
}
};
var o2 = new API2;
o2.getName(console.log).setName("Menw").getName(console.log);
  
 


Ïà¹ØÎĵµ£º

ÍøÒ³ÖÆ×÷Javascript¾­µäС¼¼ÇÉ

 ×ª×Ôhttp://topic.csdn.net/u/20091014/12/44b0ac69-5228-429b-854a-a91e3736f1d4.html?64368
ÿһÏî¶¼ÊÇJSÖеÄС¼¼ÇÉ£¬µ«Ê®·ÖµÄʵÓã¡
1.document.write(”"); Êä³öÓï¾ä
2.JSÖеÄ×¢ÊÍΪ//
3.´«Í³µÄHTMLÎĵµË³ÐòÊÇ:document->html->(head,body)
4.Ò»¸öä¯ÀÀÆ÷´°¿ÚÖеÄDOM˳ÐòÊÇ:window->(navig ......

javascript Êý×é

 optionsÊý×é
¡¡¡¡¸ÃÊý×éÊÇselect¶ÔÏóµÄÒ»¸öÊôÐÔ,¼´Ñ¡Ôñ¿òÖеÄËùÓÐÑ¡Ïî(<OPTION>)µÄÒ»¸öÁÐ±í¡£
¡¡¡¡ÊôÐÔ
¡¡¡¡defaultSelected Ñ¡ÏîÁбíÖеÄȱʡѡÏî
¡¡¡¡index Ñ¡ÏîÁбíÖÐijѡÏîµÄË÷ÒýλÖÃ
¡¡¡¡length Ñ¡ÏîÁбíÖеÄÑ¡ÏîÊý(<OPTIONS>)
¡¡¡¡name Ñ¡ÏîÁбíµÄÃû×Ö(NAMEÌØÐÔ)
¡¡¡¡selected ±íÊ¾Ñ ......

JavaScriptÎĵµ¶ÔÏó(DOM)

 JavaScriptÎĵµ¶ÔÏó(DOM)
navigator
screen
window
history
location
frames[]; Frame
document
anchors[]; links[]; Link
applets[]
embeds[]
forms[]; Form
Button
Checkbox
elements[]; Element
Hidden
Password
Radio
Reset
Select
options[]; Option
Submit
Text
......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ