condensing / simplifying multiple operations
Hello jQuery community -
I have the following code, which works great, but i'm looking for any suggestions that could help condense / simplify this code, considering it's essentially doing the same thing, in exception to the different input element + it's associated value.
For clarity's sake, i've highlighted the differentiators in red.
- //CLEAR / RESET PRE-DEFINED FORM FIELD VALUES
- $("div#name input").focus(function() {
- if ($(this).val() == "Your name") {
- $(this).val('');
- $(this).css({
- 'font-style': 'normal',
- 'color': '#333'
- });
- }
- });//End
-
- $("div#email input").focus(function() {
- if ($(this).val() == "Your email") {
- $(this).val('');
- $(this).css({
- 'font-style': 'normal',
- 'color': '#333'
- });
- }
- });//End