Facebook-Like Leave a Comment Script with jQuery
We can easily create Facebook-Like textbox for leaving comments in an easy and cool way using jQuery, I am leaving an example below.
You can see an implementation working here
HTML
<textarea class="comment_empty">Write a comment</textarea><br /> <input type="submit" id="submit" value="Submit" style="display: none" />
jQuery
$(document).ready(function(){
var submit = $("#submit");
$("textarea").blur(function() {
if ($(this).val() == "") {
$(this).val("Write a comment")
.removeClass("comment_filled")
.addClass("comment_empty");
submit.hide();
}
}).focus(function() {
if ($(this).val() == "Write a comment") {
$(this).val("")
.removeClass("comment_empty")
.addClass("comment_filled");
submit.show();
}
});
});
CSS
.comment_empty {
color: gray;
height: 30px;
}
.comment_filled {
color: black;
height: 100px;
}

Niti Dentico said:
Why the if-statements? It's doing it's job without it.
Carlos Rivera said:
testing... very nice
German Rodriguez said:
You need the IFs. because we dont want to lose what the user has written when the textbox loses focus
Amit Patil said:
asas
Amit Patil said:
http://www.amitpatil.me/demos/facebook-like-comment-script/facebook-like-comment-script/
Chad Donoghue said:
testing 123
Maung Ching said:
hi testing