Created
June 16, 2012 16:06
-
-
Save MikeRogers0/2941793 to your computer and use it in GitHub Desktop.
Creating More User Friendly Forms with jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <!– Pull the jQuery base from Google, it has CDN so it should be a little faster. –> | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
$("form input, form input, form textarea").css('color', '#484848'); | |
$("form .submit").css('color', '#000'); | |
$("form label").hover(function () { | |
$("#infobox").html($(this).attr('title')); | |
}); | |
$("form input, form input, form textarea").focus(function () { | |
if($(this).val() == $(this).attr('title')){ | |
$(this).val(''); | |
} | |
$(this).css('color', '#000'); | |
}); | |
$("form input, form input, form textarea").blur(function () { | |
if($(this).val() == ”){ | |
$(this).val($(this).attr('title')); | |
$(this).css('color', '#484848'); | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment