Skip to content

Instantly share code, notes, and snippets.

@gMagicScott
Created September 16, 2012 01:15
Show Gist options
  • Save gMagicScott/3730669 to your computer and use it in GitHub Desktop.
Save gMagicScott/3730669 to your computer and use it in GitHub Desktop.
jQuery to highlight (add css class) table row for form fields on focus
$(document).ready(function () {
$("input,select,textarea").focus(function() {
$(this).closest("tr").addClass("curFocus")
});
$("input,select,textarea").blur(function() {
$(this).closest("tr").removeClass("curFocus")
});
});
@gMagicScott
Copy link
Author

Remember:

If you are going to use this inline within the document even though it's a bad idea, add the extra CDATA tags.

// <![CDATA[
    // code goes here
// ]]>

And as noted in the title and comment, this requires jQuery to be loaded first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment