erang placeholder js

This commit is contained in:
sanj 2010-08-30 00:11:18 +05:30
parent 1353fc4fbb
commit eab5b07dc4

View File

@ -7,8 +7,8 @@ $(document).ready(function() {
$('input, textarea').each(function() { $('input, textarea').each(function() {
var hasPlaceholder = $(this).attr("data-placeholder") == undefined ? false : true; var hasPlaceholder = $(this).attr("data-placeholder") == undefined ? false : true;
if (hasPlaceholder) { if (hasPlaceholder) {
var placeholderText = $(this).data("placeholder") = $(this).attr("data-placeholder"); $(this).data("placeholder") = $(this).attr("data-placeholder");
$(this).addClass("placeholder").val(placeholderText); $(this).addClass("placeholder").val($(this).data("placeholder"));
$(this).focus(function() { $(this).focus(function() {
var currText = $(this).val(); var currText = $(this).val();
if (currText == $(this).data("placeholder")) { if (currText == $(this).data("placeholder")) {