<script> function ReplaceDemo(a){ var r, re; // 声明变量。 var ss = "The man hit the ball with the bat.\n"; ss += "while the fielder caught the ball with the glove."; re = /The/g; // 创建正则表达式模式。 r = ss.replace(re, a); // 用 "A" 替换 "The"。 return(r); // 返回替换后的字符串。 } alert(ReplaceDemo("fdsafdasfdsafdsa")); </script>
<script>
function ReplaceDemo(a){ var r, re; // 声明变量。
var ss = "The man hit the ball with the bat.\n";
ss += "while the fielder caught the ball with the glove.";
re = /The/g; // 创建正则表达式模式。
r = ss.replace(re, a); // 用 "A" 替换 "The"。
return(r); // 返回替换后的字符串。
}
alert(ReplaceDemo("fdsafdasfdsafdsa"));
</script>
document.all.id.innerHTML ="<a..........
----------------------------------------------<font id=hello>aaa</font><br>
<input type=button value=方式1 onclick="hello.innerText='fdsafdas'"><br>
<input type=button value=方式1 onclick="hello.innerHTML='<b>fdsafdas</b>'"><br>
replace还不会,怎样用变量代替
re = /The/g; 的“The”?