Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ȨÍþÖ¸ÄÏ(µÚËÄ°æ)][cookie]

//¹¹Ô캯Êý£ºÓÃÖ¸¶¨µÄÃû×ֺͿÉÑ¡µÄÐÔÖÊΪָ¶¨µÄÎĵµ´´½¨Ò»¸öcookie¶ÔÏó¡£
//²ÎÊý£º
// doucment:±£´æcookieµÄDocument¶ÔÏó
// name£º Ö¸¶¨cookieÃûµÄ×Ö·û´®
// hours£º Number£¬Ö¸¶¨´ÓÏÖÔÚÆðµ½cookie¹ýÆÚµÄСʱÊý
// path: String£¬Ö¸¶¨cookieµÄ·¾¶ÐÔÖÊ
// domain£º String, Ö¸¶¨cookieµÄÓòÐÔÖÊ
// secure: Bo ......

ºËÐÄJavaScript»ù´¡ 2£¨Ñ§Ï°±Ê¼Ç£©

²Î¿¼×ÊÁÏ:¡¶javascriptȨÍþÖ¸ÄϵÚÎå°æ¡·
===============±äÁ¿==============
1¡¢javaScriptÊÇÒ»ÖÖÈõÀàÐ͵ÄÓïÑÔ£¬ÓÃvarÓï¾ä¼´¿ÉÉùÃ÷Ò»¸ö±äÁ¿¡£
2¡¢Èç¹û²»ÓÃvarÓï¾äÉùÃ÷¶øÖ±½Ó¸øÒ»¸ö±äÁ¿¸³Öµ£¬ÄÇÕâ¸ö±äÁ¿½«±»ÒþʽÉùÃ÷Ϊȫ¾Ö±äÁ¿¡£
3¡¢Èç¹ûº¯ÊýÄÚ²¿ÓÃvarÓï¾äÉùÃ÷ÁËÒ»¸öÓëijȫ¾Ö±äÁ¿Í¬ÃûµÄ±äÁ¿£¬ÔòÔÚº¯ÊýÖÐÈ«¾Ö±äÁ¿±»ÆÁ±ÎÁË ......

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

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

javascriptÊý×é¼°Æä²Ù×÷

±¾ÎĽéÉÜÈçϼ¸¸ö·½ÃæµÄÄÚÈÝ:
1.ÈçºÎ´´½¨Êý×é
2.ÈçºÎ¶ÔÊý×é½øÐвÙ×÷£¨Ìí¼Ó,ɾ³ý,¶ÁÈ¡)
3.Êý×é³£¼û·½·¨ºÍÊôÐÔ
ÈçºÎ´´½¨Ò»¸öÊý×é,Ò»°ãµØ¸ù¾Ý³õʼ»¯É趨¼òµ¥·ÖΪ3ÖÖ:
1.µ¥´¿´´½¨Êý×é:
var arr=new Array();
Òªµã:ÓÃnew¹Ø¼ü×Ö´´½¨Êý×é¶ÔÏóArray(),Array()¶ÔÏóÊÇÒ»¸ö±¾µØÀà,¿ÉÒÔÓÃnew´´½¨Ò»¸ö¶ÔÏóºóʹÓÃ
2.´´½¨Ê ......

ÓÃJavascript»ñÈ¡Ò³ÃæÔªËصÄλÖÃ

תÔØ×Ô£ºhttp://www.ruanyifeng.com/blog/2009/09/find_element_s_position_using_javascript.html
Áíһƪ£ºhttp://blog.csdn.net/ivan820819/archive/2009/09/03/4515122.aspx
ÖÆ
×÷
ÍøÒ³µÄ¹ý³ÌÖУ¬ÄãÓÐʱºòÐèÒªÖªµÀij¸öÔªËØÔÚÍøÒ³ÉϵÄÈ·ÇÐλÖá£
ÏÂÃæµÄ½Ì³Ì×ܽáÁËJavascriptÔÚÍøÒ³¶¨Î»·½ÃæµÄÏà¹ØÖª
ʶ¡£
Ò»¡¢ÍøÒ³µ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ