mootools_function的介绍

Function: Function.from 返回方法;

Function: Function.attempt 尝试方法

Function.attempt(fn[, fn, fn, fn, ...]);

Function method: extend 继承;

var myFunction = function(){};
myFunction.extend('alert', function(text){
alert(text);
});
myFunction.alert('Hello!'); // alerts Hello!

// Using objects
myFunction.extend({
alert: function(text){
alert(text);
}
});

Function method: implement 为原型添加方法。

var myFunction = function(){};
myFunction.implement('alert', function(text){
alert(text);
});
var myInstance = new myFunction();
myInstance.alert('Hello!'); // alerts Hello!

// Using objects
myInstance.implement({
alert: function(text){
alert(text);
}
});

Function method: bind 绑定事件

function myFunction(){
// Note that 'this' here refers to window, not an element.
// the function must be bound to the element we want to manipulate.
this.setStyle('color', 'red');
};
var myBoundFunction = myFunction.bind(myElement);
myBoundFunction(); // makes myElement's text red

// To show how bind works the following example:
var myBoundFunction = myFunction.bind(anyVar);
// is roughly equivalent with
var myBoundFunction = function(){
return myFunction.call(this);
};

Function method: delay 延时方法发生 var timeoutID = myFunction.delay(delay[, bind[, args]]);

var myFunction = function(){ alert('moo! Element id is: ' + this.id); };

//wait 50 milliseconds, then call myFunction and bind myElement to it
myFunction.delay(50, myElement); // alerts: 'moo! Element id is: ... '

//an anonymous function which waits a second and then alerts
(function(){ alert('one second later...'); }).delay(1000);

//to stop the delay, clearTimeout can be used like so:
var timer = myFunction.delay(50);
clearTimeout(timer);

 

Function method: periodical 周期性执行方法

ar Site = { counter: 0 };
var addCount = function(){ this.counter++; };
addCount.periodical(1000, Site); //adds the number of seconds at the Site.

// the interval can be stopped using the clearInterval function
var timer = myFunction.periodical(1000);
clearInterval(timer);





 









转载于:https://www.cnblogs.com/santiago1983/archive/2012/02/15/mootools_function.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值