[mootools] Element.implement
Elementにimplementを施す例。
hoverという関数をエレメントに追加する。
Elementのfunction追加ってことかな。addEventとかgetClassみたいなもの。
Element.implement({
'hover': function(fn1,fn2) {
return this.addEvents({
'mouseenter': function(e) {
fn1.attempt(e,this);
},
'mouseleave': function(e) {
fn2.attempt(e,this);
}
})
}
});
使ってみる。
$$('.navi li').hover(
function(e){
this.fade('out');
},
function(e) {
this.fade('in');
}
);
demoはこのページのナビ部分。
attemptって何だ?
コメントする