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

³£ÓÃ:javascript×Ö·û´®º¯Êý ÊÕ²Ø

³£ÓÃ:javascript×Ö·û´®º¯Êý ÊÕ²Ø
concat
½«Á½¸ö»ò¶à¸ö×Ö·ûµÄÎı¾×éºÏÆðÀ´£¬·µ»ØÒ»¸öеÄ×Ö·û´®¡£
var a = "hello";
var b = ",world";
var c = a.concat(b);
alert(c);
//c = "hello,world"
indexOf
·µ»Ø×Ö·û´®ÖÐÒ»¸ö×Ó´®µÚÒ»´¦³öÏÖµÄË÷Òý£¨´Ó×óµ½ÓÒËÑË÷£©¡£Èç¹ûûÓÐÆ¥ÅäÏ·µ»Ø -1 ¡£
var index1 = a.indexOf("l");
//index1 = 2
var index2 = a.indexOf("l",3);
//index2 = 3
charAt
·µ»ØÖ¸¶¨Î»ÖõÄ×Ö·û¡£
var get_char = a.charAt(0);
//get_char = "h"
lastIndexOf
·µ»Ø×Ö·û´®ÖÐÒ»¸ö×Ó´®×îºóÒ»´¦³öÏÖµÄË÷Òý£¨´ÓÓÒµ½×óËÑË÷£©£¬Èç¹ûûÓÐÆ¥ÅäÏ·µ»Ø -1 ¡£
var index1 = lastIndexOf('l');
//index1 = 3
var index2 = lastIndexOf('l',2)
//index2 = 2
match
¼ì²éÒ»¸ö×Ö·û´®Æ¥ÅäÒ»¸öÕýÔò±í´ïʽÄÚÈÝ£¬Èç¹ûôÓÐÆ¥Åä·µ»Ø null¡£
var re = new RegExp(/^\w+$/);
var is_alpha1 = a.match(re);
//is_alpha1 = "hello"
var is_alpha2 = b.match(re);
//is_alpha2 = null
substring
·µ»Ø×Ö·û´®µÄÒ»¸ö×Ó´®£¬´«Èë²ÎÊýÊÇÆðʼλÖúͽáÊøλÖá£
var sub_string1 = a.substring(1);
//sub_string1 = "ello"
var sub_string2 = a.substring(1,4);
//sub_string2 = "ell"
substr
·µ»Ø×Ö·û´®µÄÒ»¸ö×Ó´®£¬´«Èë²ÎÊýÊÇÆðʼλÖúͳ¤¶È
var sub_string1 = a.substr(1);
//sub_string1 = "ello"
var sub_string2 = a.substr(1,4);
//sub_string2 = "ello"
replace
ÓÃÀ´²éÕÒÆ¥ÅäÒ»¸öÕýÔò±í´ïʽµÄ×Ö·û´®£¬È»ºóʹÓÃÐÂ×Ö·û´®´úÌæÆ¥ÅäµÄ×Ö·û´®¡£
var result1 = a.replace(re,"Hello");
//result1 = "Hello"
var result2 = b.replace(re,"Hello");
//result2 = ",world"
search
Ö´ÐÐÒ»¸öÕýÔò±í´ïʽƥÅä²éÕÒ¡£Èç¹û²éÕҳɹ¦£¬·µ»Ø×Ö·û´®ÖÐÆ¥ÅäµÄË÷ÒýÖµ¡£·ñÔò·µ»Ø -1 ¡£
var index1 = a.search(re);
//index1 = 0
var index2 = b.search(re);
//index2 = -1
slice
ÌáÈ¡×Ö·û´®µÄÒ»²¿·Ö£¬²¢·µ»ØÒ»¸öÐÂ×Ö·û´®£¨Óë substring Ïàͬ£©¡£
var sub_string1 = a.slice(1);
//sub_string1 = "ello"
var sub_string2 = a.slice(1,4);
//sub_string2 = "ell"
split
ͨ¹ý½«×Ö·û´®»®·Ö³É×Ó´®£¬½«Ò»¸ö×Ö·û´®×ö³ÉÒ»¸ö×Ö·û´®Êý×é¡£
var arr1 = a.split("");
//arr1 = [h,e,l,l,o]
length
·µ»Ø×Ö·û´®µÄ³¤¶È£¬Ëùν×Ö·û´®µÄ³¤¶ÈÊÇÖ¸Æä°üº¬µÄ×Ö·ûµÄ¸öÊý¡£
var len = a.length();
//len = 5
toLowerCase
½«Õû¸ö×Ö·û´®×ª³ÉСд×Ö


Ïà¹ØÎĵµ£º

javascript ´òÓ¡(ÈËÔÆÒàÔÆ,ÎÒ´íÁË)

<html>
<head>
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
<title>***WSOFT.NET***</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--media=print Õâ¸öÊôÐÔ¿ÉÒÔÔÚ´òӡʱÓÐЧ-->
<style ......

JavaScript ×Ö·û´®Ìæ»»ºÍDOM²Ù×÷¼¼ÇÉ


×îµÍÒ»Ö±ÔÚдJavaScript,¾Í±¾ÈËÓöµ½µÄÁ½¸öÎÊÌâÒÔ¼°½â¾ö·½·¨¸ø´ó¼Ò·ÖÏíÒ»ÏÂ.
1,µã»÷Ò»¸ö°´Å¥,´´½¨Ò»¶ÎHTML´úÂëºÍÏÖÓеÄһģһÑù,µ«ÊÇÀïÃæËùÓÐIDµÄ²ÎÊýºÍ·½·¨ÀïÃæµÄ²ÎÊýÒª¸Ä±ä,²ÎÊý¶¼ÊÇÈô¸É¸ö×Öĸ+Êý×Ö×é³É.д´½¨³öÀ´µÄHTML´úÂëƬ¶ÎÒªÀïÃæµÄ²ÎÊý±ä³É×Öĸ²»±ä,Êý×ÖÒª+1.
Èç,±ä֮ǰµÄ´úÂë,
<div id=”testdiv1&rd ......

[¶ÁÊé±Ê¼Ç][JavaScriptȨÍþÖ¸ÄÏ(µÚËÄ°æ)][DOM]

1.HTMLÎĵµÊ÷Ðαíʾ
2.Node[] Node.childNodes 
//·µ»ØNode¶ÔÏóµÄËùÓÐ×Ö½Úµã
3.Node.firstChild  /  lastChild  /nextSibling(ÏÂÒ»¸öÐֵܽڵã)  / previousSibling (ÉÏÒ»¸öÐֵܽڵã)  / parentNode
ÊôÐÔ
4.Node.appendChild()  /  removeChild()  /  replaceChil ......

JSONÊÇʲô£¿ÎªJavaScript×¼±¸µÄÊý¾Ý¸ñʽ

»¹²»Á˽âJSONÊÇʲô?¿´ÁËÏÂÃæÕâƪÎÄÕ£¬Äú¶ÔJSONÊÇʲôӦ¸ÃÄܹ»ÓÐÁËÒ»¸ö±È½ÏÇåÎúµÄ¸ÅÄî¡£
¡¡¡¡JSON ¼´ JavaScript. Object Natation£¬ËüÊÇÒ»ÖÖÇáÁ¿¼¶µÄÊý¾Ý½»»»¸ñʽ£¬·Ç³£ÊʺÏÓÚ·þÎñÆ÷Óë JavaScript. µÄ½»»¥¡£±¾ÎĽ«¿ìËÙ½²½â JSON ¸ñʽ£¬²¢Í¨¹ý´úÂëʾÀýÑÝʾÈçºÎ·Ö±ðÔÚ¿Í»§¶ËºÍ·þÎñÆ÷¶Ë½øÐÐ JSON ¸ñʽÊý¾ÝµÄ´¦Àí¡£
¡¡¡¡¾¡¹ ......

ѧϰ¡¶JavaScript¸ß¼¶³ÌÐòÉè¼Æ¡·Ñ§Ï°±Ê¼Ç£¨¶þ£©

Ò»¡¢deleteÔËËã·ûɾ³ý¶ÔÒÔÇ°¶¨ÒåµÄ¶ÔÏóÊôÐÔ»ò·½·¨µÄÒýÓãº
    var o=new Object();
    o.name="hello";
    alert(o.name);    //Êä³ö“hello”
    delete o.name£»
    alert(o.name);   //Êä³ö& ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ