Created
March 19, 2012 15:00
-
-
Save Gaya/2115385 to your computer and use it in GitHub Desktop.
Placeholder script jQuery
This file contains 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
/* | |
* Short jQuery method of making placeholders for all the browsers. | |
* | |
* Use the following HTML markup to make this work: | |
* <input type="text" class="placeholder" value="Your name" data-standard="Your name" /> | |
*/ | |
$(".placeholder").focus(function () { | |
if ($(this).val() == $(this).attr("data-standard")) { | |
$(this).val("").addClass("active"); //Add class for other styling | |
} | |
}).blur(function () { | |
if ($(this).val() == $(this).attr("data-standard") || $(this).val() == "") { | |
$(this).val($(this).attr("data-standard")).removeClass("active"); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment