/ Published in: jQuery

This adds a class to focused form elements (helpful for IE6/7), as well as adds a class to the input's parent (in this case, named "form-field").
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$("input, textarea", $("form")).focus(function(){ $(this).addClass("focus"); $(this).parents(".form-field").addClass("cur"); }); $("input, textarea", $("form")).blur(function(){ $(this).removeClass("focus"); $(this).parents(".form-field").removeClass("cur"); });
Comments
