Skip to content

Instantly share code, notes, and snippets.

@Agneli
Last active August 29, 2015 13:56
Show Gist options
  • Save Agneli/8974886 to your computer and use it in GitHub Desktop.
Save Agneli/8974886 to your computer and use it in GitHub Desktop.
Placeholder effect with jQuery
<!--HTML-->
<input type="text" name="email" id="email" value="digite seu e-mail" />
<!--Javascript (jQuery)-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$("#email").focus(function() {
if ($(this).val() === "digite seu e-mail") {
$(this).val("");
}
});
$("#email").focusout(function() {
if ($(this).val() === "") {
$(this).val("digite seu e-mail");
}
});{
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment