View Full Version : jquery: textarea - 'Write a comment...' and 'What's on your mind?' like facebook

07-19-2009, 03:58 AM

I would like to know how to make a textarea like the ones in facebook, which they always have default text 'Write a comment...' or 'What's on your mind?' - they will disappear when u click on the textarea, but they will change back to default when u click outside the textarea again...

hope you understand i am trying to explain above.

any online references please...?

many thanks,

Philip M
07-19-2009, 07:47 AM
It does not seem to make much sense to revert to the default text as soon as the user clicks elsewhere in the document.

<textarea id = "txt1" rows = "6" cols = "25" onclick = "erase()">Write a comment......</textarea>

<script type = "text/javascript">
var flag = true;
function erase() {
if (flag) {
document.getElementById("txt1").value = "";
flag = false;

Quizmaster: What "R" was Hilary Clinton's maiden name?
Contestant: Er, um . .. is it Rottweiler?