水木社区手机版
首页
|版面-Web开发(WebDev)|
新版wap站已上线
返回
1/1
|
转到
主题:js的怎么取字符串的第一个到倒数第三个啊?
楼主
|
ora1555
|
2017-11-15 20:27:12
|
只看此ID
substr(0,-2)好像不行哦
--
FROM 202.45.129.*
1楼
|
a0123456789q
|
2017-11-16 11:02:17
|
只看此ID
You have to be very stupid to ask such a simple question.
A simple search solves you problem:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
str.substr(start[, length])
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring
str.substring(indexStart[, indexEnd])
so you should use:
substring(0, yourTxt.length-3)
【 在 ora1555 (ora1555) 的大作中提到: 】
: substr(0,-2)好像不行哦
--
FROM 183.95.135.*
2楼
|
wangchenmlg
|
2017-11-18 20:31:23
|
只看此ID
赞内涵
【 在 a0123456789q 的大作中提到: 】
: You have to be very stupid to ask such a simple question.
: A simple search solves you problem:
:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr
: ...................
--
FROM 101.40.41.*
1/1
|
转到
选择讨论区
首页
|
分区
|
热推
BYR-Team
©
2010.
KBS Dev-Team
©
2011
登录完整版