该方法返回一个string对象的一个子集。
语法
string.substring(indexa, [indexb])
下面是参数的详细信息:
返回值:
例子:
<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>
这将产生以下结果:
(1,2): p (0,10): apples are (5): s are round, and apples are juicy.
如对本文有疑问, 点击进行留言回复!!
offset、client、scroll (width,height、left,top、X,Y)
网友评论