Posted By

dougunderscorenelson on 04/28/09


Tagged

form jquery focus field


Versions (?)


Advertising

Website Promotion DIRECTORY is a crucial factor for all websites that need to gain better organic search engine rankings and increase website traffic.
Submitting your website as part of your Web Promotion strategy to our SEO friendly and high traffic Business Directory for review is an excellent way to gain a valuable backlink and increase your websites visibility online.

Submit Site


Who likes this?

2 people have marked this snippet as a favorite

sulfurito
talbs


Adding a Focus class to Forms


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
  1. $("input, textarea", $("form")).focus(function(){
  2. $(this).addClass("focus");
  3. $(this).parents(".form-field").addClass("cur");
  4. });
  5. $("input, textarea", $("form")).blur(function(){
  6. $(this).removeClass("focus");
  7. $(this).parents(".form-field").removeClass("cur");
  8. });

Report this snippet 

You need to login to post a comment.