javascriptÖÐreplace()
javascriptÖÐreplace()
ÔÚjavascriptÖУ¬StringµÄº¯Êýreplace()¼òֱ̫ÈÃÈËϲ°®ÁË¡£ËüÁé»î¶øÇ¿´óµÄ×Ö·ûÌæ»»´¦ÀíÄÜÁ¦£¬ÈÃÎÒ²»½ûÏëÏò´ó¼Ò½éÉÜËü¡£
¡¡¡¡replace()×î¼òµ¥µÄËãÊÇÄÜÁ¦¾ÍÊǼòµ¥µÄ×Ö·ûÌæ»»¡£Ê¾Àý´úÂëÈçÏ£º
<script language="javascript">
var strM = "javascript is a good script language";
//ÔÚ´ËÎÒÏ뽫×ÖĸaÌæ»»³É×ÖĸA
alert(strM.replace("a","A"));
</script>
¡¡¡¡ÎÒÏë´ó¼ÒÔËÐкó¿ÉÒÔ¿´µ½½á¹û£¬ËüÖ»Ìæ»»ÁËÊ××Öĸ¡£µ«Èç¹û¼ÓÉÏÕýÔò±í´ïʽ½á¹û¾Í²»Ò»ÑùÁË£¡ºÇºÇ£¬Ã»´í¡£replace()Ö§³ÖÕýÔò±í´ïʽ£¬Ëü¿ÉÒÔ°´ÕÕÕýÔò±í´ïʽµÄ¹æÔòÆ¥Åä×Ö·û»ò×Ö·û´®£¬È»ºó¸øÓèÌæ»»£¡
<script language="javascript">
var strM = "javascript is a good script language";
//ÔÚ´ËÎÒÏ뽫×ÖĸaÌæ»»³É×ÖĸA
alert(strM.replace(/a/,"A"));
</script>
¡¡¡¡ºÇºÇ£¬ÄúÒ»¶¨·¢ÏÖÁË¡£ÕâÑù»¹ÊÇÖ»Ìæ»»Á˵ÚÒ»¸ö×Öĸa¡£Èç¹ûÄúÊìϤÕýÔò£¬ÄÇÕâ¾ÍÄѲ»×¡Äú¡£ÉÔ¼ÓÐ޸ľÍOKÁË¡£
<script language="javascript">
var strM = "javascript is a good script language";
//Ôڴ˽«×ÖĸaÈ«²¿Ìæ»»³É×ÖĸA
alert(strM.replace(/a/g,"A"));
</script>
¡¡¡¡»¹¿ÉÒÔÕâÑù£¬¿´¿´Ð§¹û£¡
<script language="javascript">
var strM = "javascript is a good script language";
alert(strM.replace(/(javascript)\s*(is)/g,"$1 $2 fun. it $2"));
</script>
¡¡¡¡ÎÒÕâ¶ù¾ÙµÄÀý×Ó¶¼ÊǺܼòµ¥µÄÓ¦Óã¬replace()Ôڴ˵ãÉÏÓëÄúʹÓÃÕýÔò±í´ïʽµÄÄÜÁ¦³ÉÕý±È¡£ÄúÕýÔò±í´ïʽԽǿ£¬ºÇºÇ£¬ÄÇÄú¾Í»áÔ½·è¿ñµÄ°®ÉÏËü¡£
¡¡¡¡µ±È»£¬ÎÒÕâ¶ùÍƼöreplace()µÄÔÒò²¢²»ÒòΪËüÄÜÓëÕýÔò±í´ïʽºÏ×÷£¬¶øÔÚÓÚËü»¹ÄÜÓ뺯Êý½øÐкÏ×÷£¬·¢»Ó³öÇ¿´óµÄ¹¦ÄÜ¡£
¡¡¡¡ÏÈ¿´¿´¼òµ¥Àý×Ó£º½«ËùÓе¥´ÊÊ××Öĸ»»³É´óд¡£
<script language="javascript">
var strM = "javascript is a good script language";
function change(word)
{
¡¡return word.indexOf(0).toUpperCase()+word.substring(1);
}
alert(strM.replace(/\b\w+\b/g,change));
</script>
¡¡¡¡ÓÉÉÏ¿ÉÖª£¬µ±ÕýÔò±í´ïʽÓÐ"g"±ê־ʱ£¬´ú±í½«´¦ÀíÕû¸ö×Ö·û´®£¬¼´º¯ÊýchangeµÄ±ä»»½«Ó¦ÓÃÓÚËùÓÐÆ¥ÅäµÄ¶ÔÏ󡣶ø¸Ãº¯ÊýÓÐÈý¸ö»ò¸ü¶à²ÎÊý£¬¾ßÌå¸öÊýÊÓÕýÔò±í´ïʽ¶ø¶¨¡£
¡¡¡¡ÓÐÁ˺¯ÊýÓëÕýÔò±í´ïʽµÄÅäºÏ£¬
Ïà¹ØÎĵµ£º
var docEle = function() {
return document.getElementById(arguments[0]) || false;
}
function cloDiv(){
var overlayID="overlay";
var msgID = "overlayMsg";
document.body.removeChild(docEle(overlayID));
document.body.removeChild(docEle(msgID));
}
function openNewDiv() {
......
1 ´´½¨½Å±¾¿é
1: <script language=”JavaScript”>
2: JavaScript code goes here
3: </script>
2 Òþ²Ø½Å±¾´úÂë
1: <script language=”JavaScript”>
2: <!--
3: document.write(&ldquo ......
FusionChart ¾Í²»ÓýéÉÜÁË°Ñ£¬Ò»¿îÖ§³Ö¶àÖÖÓïÑÔµÄͼ±íÉú³É¿Ø¼þ£¬Éú³ÉµÄͼ±í·á¸»£¬ÃÀ¹Û£¬ÇÒÓж¯Ì¬¸Ð£¬ÒòΪËüÉú´æµÄ¶«Î÷¾ÍÊÇÒ»¸öflash¡£Ò»Ï½éÉÜÒ»ÏÂËüµÄjavascript ʵÏÖ·½Ê½°Ñ¡£
·Ï»°ÉÙ˵£¬Ö±½ÓÉÏʵÀý
<HTML>¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡ <HEAD>¡¡¡¡¡¡¡¡¡¡¡¡
¡¡¡¡¡¡¡¡¡¡ <SCRIPT LANGUAGE="Javascri ......
Array×÷ΪJavaScriptµÄÒ»¸öÄÚÖöÔÏó£¬ÓÐ×ÅÇ¿´óµÄ¹¦ÄÜ£»Ïà¶ÔÓÚÆäËûÄÚÖöÔÏóÀ´Ëµ£¬ËûÓÐ×ÅÌØÊâµÄÓ÷¨£¬ÏÂÃæ¶Ô˵˵×Ô¼º¶ÔArrayµÄÓ÷¨µÄÒ»¸öС×ܽ᣺
1>ÓÃ;һ£ºÊý×é
Êý×é×î´ó´æ´¢Êý¾ÝΪËÄÊ®¶àÒÚ¸ö£¬Õâ¸ö¿Õ¼ä×ã¹»ÓÃÁË£¬ËùÒÔÊý×é¿ÉÒÔËæ±ãµÄÀ©ÈÝ¡£ÏÂÃæ¶Ô³£Óõ ......