è·åæå®å符å/åç
å符串:
<script type="text/javascript">
/*
string å符串;
str æå®å符;
split(),ç¨äºæä¸ä¸ªå符串åå²æå符串æ°ç»;
split(str)[0],读åæ°ç»ä¸ç´¢å¼ä¸º0çå¼ï¼ç¬¬ä¸ä¸ªå¼ï¼,æææ°ç»ç´¢å¼é»è®¤ä»0å¼å§;
*/
function getStr(string,str){
var str_before = string.split(str)[0];
var str_after = string.split(str)[1];
alert('åï¼'+str_before+' - åï¼'+str_after);
}
</script>
<input type="button" onClick="getStr('string','r');" value="è·åå¼" />
è·åå符串ä¸æå®ä½ç½®çå符ï¼
<html>
<head>
<title>åå¾å符串ä¸æå®ä½ç½®çå符 - Liehuo.Net</title>
</head>
<body>
<script language="javascript">
<!--
str = "JavaScript";
str1 = str.charAt(0);
str2 = str.charAt(4);
document.write("str=" + str + "<br>");
document.write("第1个å符æ¯:" + str1 + "<br>");
document.write("第5个å符æ¯:" + str2 + "<br>");
//-->
</script>
</body>
</html>