JavaScript ¹¹½¨ÀàºÍ´´½¨¶ÔÏóµÄ·½Ê½
1>¹¤³§º¯ÊýÀ´´´½¨¶ÔÏó(Factory)
function createCar(){
var obj = new Object;
obj.name = "BWM";
obj.show = function(){
alert(this.name);
}
return obj;
}
var car1 = createCar();
var car2 = createCar();
car1.show();
car2.show();
2>¹¹Ô캯Êý´´½¨¶ÔÏó(Constructor)
function Car(name){
this.name = name;
this.show = function(){
alert(this.name);
}
}
Car.prototype.say = function(){
alert("hello");
}
var car = new Car("BMW");
car.show();
car.say();
3>ÔÐÍ£¨prototype£©´´½¨¶ÔÏó
function Car(){}
Car.prototype.name = "BMW";
Car.prototype.show = function(){
alert(this.name);
}
Car.prototype.say = function(){
alert("Hiloo");
}
var car = new Car();
car.show(); car.say();
4>¹¹Ôì && ÔÐÍ£ºÍƼöʹÓ㬵«ÊÇÀí½âÆðÀ´ÓеãÄ£ºý
/*
¹¹Ô캯ÊýÊÇÀ´³õʼ»¯·Çº¯ÊýÊôÐÔµÄ
*/
function Car(name){
this.name = name;
}
Car.prototype.show = function(){
alert(this.name);
}
Car.prototype.say = function(){
alert("hiloo");
}
var car = new Car("BMW");
car.show(); car.say();
5>Dynamic Prototype£ºÀàËÆÓÚjavaÖÐÀàµÄ´´½¨£¬ÊÇѧϰ¹ýJavaÓïÑÔ³ÌÐòÔ±³£Óõķ½Ê½
function Car(name){
this.name = name;
if(typeof Car._initialized == "undefined"){
Car.prototype.show = function(){
alert(this.name);
}
Car._initialized = true;//¸Ä±äÄ¿µÄÊÇ£¬Ö´ÐÐÒ»´Î
}
}
var car = new Car("BMW");
car.show();
Ïà¹ØÎĵµ£º
1ÅжÏselectÑ¡ÏîÖÐ ÊÇ·ñ´æÔÚValue="paraValue"µÄItem
2ÏòselectÑ¡ÏîÖÐ ¼ÓÈëÒ»¸öItem
3´ÓselectÑ¡ÏîÖРɾ³ýÒ»¸öItem
4ɾ³ýselectÖÐÑ¡ÖеÄÏî
5ÐÞ¸ÄselectÑ¡ÏîÖÐ value="paraValue"µÄtextΪ"paraText"
6ÉèÖÃselectÖÐtext="paraText"µÄµ ......
ÿ´ÎÓõÄʱºò¶¼ÒªÕÒÒ»±é×ÊÁÏ£¬×ÁÄ¥Ò»±éÓï·¨£¬²»Ê¤Æä·³£¬ÖÕÓÚ϶¨¾öÐÄ°ÑËûÃǶ¼¼ÇÏÂÀ´£¬Ò»´ÎÐԸ㶨£¬ÓÀ¾øºó»¼£¡:)
Ò»¡¢Ê²Ã´ÊÇÕýÔò±í´ïʽ£¿
¼òµ¥µØ˵£¬¾ÍÊÇ»ùÓÚ×Ö·û´®µÄģʽƥÅ乤¾ß¡£Êµ¼ÊÓ¦ÓÃÖаüÀ¨×Ö·û´®µÄ²éÕÒ¡¢ÌáÈ¡¡¢Ìæ»»µÈµÈ¡£
¶þ¡¢»ù±¾Óï·¨
JavascriptÖеÄÕýÔò±í´ïʽµÄÐÎʽһ ......
FusionChart ¾Í²»ÓýéÉÜÁË°Ñ£¬Ò»¿îÖ§³Ö¶àÖÖÓïÑÔµÄͼ±íÉú³É¿Ø¼þ£¬Éú³ÉµÄͼ±í·á¸»£¬ÃÀ¹Û£¬ÇÒÓж¯Ì¬¸Ð£¬ÒòΪËüÉú´æµÄ¶«Î÷¾ÍÊÇÒ»¸öflash¡£Ò»Ï½éÉÜÒ»ÏÂËüµÄjavascript ʵÏÖ·½Ê½°Ñ¡£
·Ï»°ÉÙ˵£¬Ö±½ÓÉÏʵÀý
<HTML>¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡ <HEAD>¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡ <SCRIPT LANGUAGE="Javascri ......
µÚÒ»ÖÖ·½·¨£ºÊ¹ÓÃinsertRowÌí¼ÓÐУ¬Ê¹ÓÃinsertCellÌí¼Óµ¥Ôª¸ñ£¬ÔÙÓÃinnerHTMLÌî³äµ¥Ôª¸ñ¡£Ê¹ÓÃdeleteRowɾ³ýÐУ¬´úÂëÈçÏ£º
Javascript´úÂ룺
function addRow()
{
var root = document.getElementById("tbody")
var&nb ......
½ñÌìÍ·¶ù¸´²é´úÂ룬½á¹û·¢ÏÖÓеÄÒ³Ã沢ûÓÐÏàÓ¦µÄDOMÔªËØ£¬µ¼Öµ÷ÓÃfuction³ö´í¡£²ÉÓÃJavaScriptÖÐarguments¶ÔÏó¿ÉÒÔºÜÇáËɵĽâ¾öÕâ¸öÎÊÌ⣬¶ø²»ÐèÒªÔÙÈ¥ÅжÏÔªËØÖ®ÀàµÄ¡£so Good£¡
JavaScriptÖÐargumentsº¯Êý¶ÔÏóÊǸöÔÏó´ú±íÕýÔÚÖ´Ðеĺ¯ÊýºÍµ÷ÓÃËüµÄº¯ÊýµÄ²ÎÊý¡£Ê¹Ó÷½·¨£º
[function.]arguments[n ]
ÆäÖÐfunctionÊÇ ......