substr(start,length)方法用来在字符串中截取从start开始指定length的字符
stringObject.substr(start,length)
例如
<script type="text/javascript">
var str="Hello world!"
document.write(str.substr(3)
)
</script>
输出:
lo world!
再比如
<script type="text/javascript">
var str="Hello world!"
document.write(str.substr(3,3)
)
</script>
输出:
lo(空格) !!!注意lo后面还有空格哦