请帮助用Prototype替换这些jQuery函数:
$("button,input,label,select,textarea").bind('mouseover mouseout',
function(){$(this).toggleClass('hover')});
$("button,input,select,textarea").bind('focus blur',
function(){$(this).toggleClass('focus')});
答案 0 :(得分:4)
var toggleClass = function(name) { $(this).toggleClassName(name) }
Event.observe($$("button,input,label,select,textarea"), 'mouseover', toggleClass.bind(this, 'hover'));
Event.observe($$("button,input,label,select,textarea"), 'mouseout', toggleClass.bind(this, 'hover'));
Event.observe($$("button,input,select,textarea"), 'focus', toggleClass.bind(this, 'focus'));
Event.observe($$("button,input,select,textarea"), 'blur', toggleClass.bind(this, 'focus'));