js中substring该方法返回一个String对象的一个子集。
1、语法
string.substring(indexA, [indexB])1复制代码类型:[javascript]
下面是参数的详细信息:
indexA: 介于0和1小于字符串的长度的整数。
indexB: (可选)介于0和字符串的长度的整数。
2、返回值:
js中substring方法返回基于给定参数的新的子字符串。
3、js截取字符串方法例子:
<html> <head> <title>JavaScript String substring() Method</title> </head> <body> <script type="text/javascript"> var str = "Apples are round, and apples are juicy."; document.write("(1,2): " + str.substring(1,2)); document.write("<br />(0,10): " + str.substring(0, 10)); document.write("<br />(5): " + str.substring(5)); </script> </body> </html>
4、结果:
(1,2): p (0,10): Apples are (5): s are round, and apples are juicy.
赞助会员可免费查看更多内容!
网站运营需要成本。您的支持,就是我们更新的动力!
网站运营需要成本。您的支持,就是我们更新的动力!
关注本站更多学习内容请收藏本站或保存本站永久网址[www.axue5.com]每天更新学习资源和各种,破解软件,福利美图技术教程,线报活动等网络资源!
© 版权声明
THE END
暂无评论内容