views:

272

answers:

1

Please help to replace these jQuery functions with Prototype ones:

$("button,input,label,select,textarea").bind('mouseover mouseout',
               function(){$(this).toggleClass('hover')});
$("button,input,select,textarea").bind('focus blur',
               function(){$(this).toggleClass('focus')});
+4  A: 
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'));
David Hedlund