Skip to content

Instantly share code, notes, and snippets.

@MikeRogers0
Created June 16, 2012 16:06
Show Gist options
  • Save MikeRogers0/2941793 to your computer and use it in GitHub Desktop.
Save MikeRogers0/2941793 to your computer and use it in GitHub Desktop.
Creating More User Friendly Forms with jQuery
<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