Skip to content

Commit 397e6b8

Browse files
karmikimchy
authored andcommitted
Added jQuery placeholder "plugin" from gist [https://gist.github.com/823300]
1 parent b8cb1f2 commit 397e6b8

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

scripts/jquery.placeholder.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// (c) https://gist.github.com/823300, https://gist.github.com/379601
2+
3+
jQuery.placeholder = function() {
4+
$('[placeholder]').focus(function() {
5+
var input = $(this);
6+
if (input.hasClass('placeholder')) {
7+
input.val('');
8+
input.removeClass('placeholder');
9+
}
10+
}).blur(function() {
11+
var input = $(this);
12+
if (input.val() === '') {
13+
input.addClass('placeholder');
14+
input.val(input.attr('placeholder'));
15+
}
16+
}).blur().parents('form').submit(function() {
17+
$(this).find('[placeholder]').each(function() {
18+
var input = $(this);
19+
if (input.hasClass('placeholder')) {
20+
input.val('');
21+
}
22+
});
23+
});
24+
25+
$(window).unload(function() {
26+
$('[placeholder]').val('');
27+
});
28+
};

0 commit comments

Comments
 (0)