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

JavaScriptÖж¨ÒåÀà»ò¶ÔÏó


1£¬¶ÔÏóµÄ¹¹³É
¶ÔÏóÓÐÌØÐÔ¹¹³É(attribute)£¬¿ÉÒÔÊÇԭʼֵ£¬Ò²¿ÉÒÔÊÇÒýÓÃÖµ¡£Èç¹ûÌØÐÔ´æ·ÅµÄÊǺ¯Êý£¬Ëü½«±»¿´×ö¶ÔÏóµÄ·½·¨£¨method£©£¬·ñÔò¸ÃÌØÐÔ±»¿´×öÊôÐÔ£¨property£©¡£
2£¬¶¨ÒåÀà»ò¶ÔÏó
£¨1£©¹¤³§·½Ê½
Code
    function createCar(sColor,iDoors) {
        var oTempCar = new Object;
        oTempCar.color = sColor;
        oTempCar.doors = iDoors;
        oTempCar.showColor = function() {
            alert(this.color);
        };
        return oTempCar;
    }
    var oCar1 = createCar("red",4);
    var oCar2 = createCar("blue", 3);
    oCar1.showColor(); //Output "red"
    oCar2.showColor(); //Output "blue"
ȱµã£º
ÿ´Îµ÷Óú¯ÊýcreateCar()ʱ£¬¶¼Òª´´½¨Ðº¯ÊýshowColor()£¬Òâζ×Åÿ¸ö¶ÔÏó¶¼ÓÐ×Ô¼ºµÄshowColor()°æ±¾¡£
¸Ä½ø£º
    function showColor() {
        alert(this.color);
    }
    function createCar(sColor,iDoors) {
        var oTempCar = new Object;
        oTempCar.color = sColor;
        oTempCar.doors = iDoors;
        oTempCar.showColor = showColor;
        return oTempCar;
    }
    var oCar1 


Ïà¹ØÎĵµ£º

javascriptÖÐʼþeventÏê½â

½Å±¾ÖеÄʼþÓÐ2ÖÖÄ£ÐÍ
1¡¢  ðÅÝÐÍʼþ£ºÊ¼þÊÇ°´ÕÕ´Ó×îÌض¨µÄÄ¿±êµ½×î²»Ìض¨µÄʼþÄ¿±ê(document)µÄ˳ÐòÒÀ´Î´¥·¢¡£ÕâÊÇÕë¶Ô²»Í¬ÔªËصÄͬһʼþÀàÐÍ
È磺
<html  onclick=”handleClick()”>
<head></head>
<body onclick=”handleClick()”>
  <div ......

javascriptÅжϺº×ÖµÄËÄÖÖ·½·¨


×ֺţº´ó ÖРС
·½·¨Ò»£º×µÄ£¬×îÈÝÒ×Àí½âµÄ£¬ÇÒ¿ÉÒÔËæÒâÉèÖÃÒªÅųýµÄ×Ö·û
<script language="javascript">
function isChinese1(str){
var badChar ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
badChar += "abcdefghijklmnopqrstuvwxyz";
badChar += "0123456789";
badChar += " "+"¡¡";//°ë½ÇÓëÈ«½Ç¿Õ¸ñ
badChar ......

JavaScriptÖÐÊý×é·½·¨

shift£ºÉ¾³ýÔ­Êý×éµÚÒ»Ï²¢·µ»Øɾ³ýÔªËصÄÖµ£»Èç¹ûÊý×éΪ¿ÕÔò·µ»Øundefined
var a = [1,2,3,4,5];
var b = a.shift(); //a£º[2,3,4,5]  b£º1
unshift£º½«²ÎÊýÌí¼Óµ½Ô­Êý×鿪ͷ£¬²¢·µ»ØÊý×éµÄ³¤¶È
var a = [1,2,3,4,5];
var b = a.unshift(-2,-1); //a£º[-2,-1,1,2,3,4,5]  b£º7
×¢£ºÔÚIE6.0ϲ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ