解释清楚就给分,

mol1981 2004-07-07 04:19:52
srcID=srcElement.id.substr(0, srcElement.id.length-1);
这里的srcID会得到一个什么样的值?其中substr是做什么的?
...全文
59 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mol1981 2004-07-07
  • 打赏
  • 举报
回复
好了,我调过去了
mol1981 2004-07-07
  • 打赏
  • 举报
回复
谢谢,等我调试以下
LxcJie 2004-07-07
  • 打赏
  • 举报
回复
来个中文的

substr 方法
返回一个从指定位置开始的指定长度的子字符串。

stringvar.substr(start [, length ])

参数
stringvar

必选项。要提取子字符串的字符串文字或 String 对象。

start

必选项。所需的子字符串的起始位置。字符串中的第一个字符的索引为 0。

length

可选项。在返回的子字符串中应包括的字符个数。

说明
如果 length 为 0 或负数,将返回一个空字符串。如果没有指定该参数,则子字符串将延续到 stringvar 的最后。

示例
下面的示例演示了substr 方法的用法。

function SubstrDemo(){
var s, ss; // 声明变量。
var s = "The rain in Spain falls mainly in the plain.";
ss = s.substr(12, 5); // 获取子字符串。
return(ss); // 返回 "Spain"。
}
netying 2004-07-07
  • 打赏
  • 举报
回复
substr Method
Returns a substring beginning at a specified location and having a specified length.

stringvar.substr(start [, length ])

Arguments
stringvar

Required. A string literal or String object from which the substring is extracted.

start

Required. The starting position of the desired substring. The index of the first character in the string is zero.

length

Optional. The number of characters to include in the returned substring.

Remarks
If length is zero or negative, an empty string is returned. If not specified, the substring continues to the end of stringvar.

Example
The following example illustrates the use of the substr method.

function SubstrDemo(){
var s, ss; //Declare variables.
var s = "The rain in Spain falls mainly in the plain.";
ss = s.substr(12, 5); //Get substring.
return(ss); // Returns "Spain".
}



具体说本例,得到srcElement.id的去掉最后一个字符的子串
gjd111686 2004-07-07
  • 打赏
  • 举报
回复
srcID返回对象的ID
其中substr是截取字符串的[在你的代码中没有看到什么效果]
gjd111686 2004-07-07
  • 打赏
  • 举报
回复
Description
Returns a substring beginning at a specified location and having a specified length.
Syntax
stringvar.substr(start [, length ])
The substr method syntax has these parts:

Part Description
stringvar Required. A string literal or String object from which the substring is extracted.
start Required. The starting position of the desired substring. The index of the first character in the string is zero.
length Optional. The number of characters to include in the returned substring.


Remarks
If length is zero or negative, an empty string is returned. If not specified, the substring continues to the end of stringvar.
The following example illustrates the use of the substr method:


function SubstrDemo()
{
var s, ss;
var s = "The quick brown fox jumped over the lazy yellow dog.";
ss = s.substr(16, 3);
// Returns "fox"
return(ss);
}

87,904

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧