Sean Catchpole schrieb:
Hello,
Perhaps this would be a faster way of typing this (yet still easy to read):
$(function(){
$("fieldset").find("intput,select,textarea")
.focus(function(){ $(this).parent().addClass("on"); })
.blur(function(){ $(this).parent().removeClass("on"); });
});
Also note that http://www.jquery.com/api/ is an excellent resource for
learning jQuery.
~Sean
My suggestion:
$(function(){
var toggle = function() { $(this).parent().toggleClass('on') };
$('fieldset").find('input, select,
textarea').focus(toggle).blur(toggle);
});
I'd choose this approach in order to avoid typing the class name "on" in
more than one place (which may lead to errors if you want to change that
one and forget it somewhere - not here maybe but in larger chunks of code).
-- Klaus