返回到:Prototype – 数字处理
该方法调用回调函数N次,从0开始。回调函数调用一个参数,范围从0到数字,独占。
语法
N.times(Callback Function);
返回值
封装号码。
例子
HTML
x
23
23
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function showResult() {
8
var s = '';
9
(5).times(function(n) {
10
s += n;
11
});
12
alert("Encapsulated Number : " + s );
13
}
14
</script>
15
</head>
16
17
<body>
18
<p>Click the button to see the result.</p>
19
<br />
20
<br />
21
<input type = "button" value = "Result" onclick = "showResult();"/>
22
</body>
23
</html>
返回到:Prototype – 数字处理
阅读剩余 34%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8921.html