【www.gdgbn.com--网页配色】

javascript利用substr获取字符串的子串




<script>
function f()
{
   t=document.form1.f2.value;
   alert(t.substr(0,2));//获取左边两个字符
   alert(t.substr(t.length-2,t.length))//获取右边两个字符
   alert(t.substr(2,t.length));//去掉字符串的左边两个字符串
}
</script>

本文来源:http://www.gdgbn.com/wangyezhizuo/11741/