Notice
Recent Posts
Recent Comments
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Archives
Today
Total
관리 메뉴

Without haste, but without rest

[jquery] textarea click 글자 사라짐 본문

삽질의 리포팅

[jquery] textarea click 글자 사라짐

느린구름 2012. 3. 5. 23:34
$(function() {
    $('textarea').each(function() {
        $.data(this, 'default', this.value);
    }).focus(function() {
        if (!$.data(this, 'edited')) {
            this.value = "";
        }
    }).change(function() {
        $.data(this, 'edited', this.value != "");
    }).blur(function() {
        if (!$.data(this, 'edited')) {
            this.value = $.data(this, 'default');
        }
    });
});


<textarea>This is the default text</textarea>
<textarea>This is another text box</textarea>