...

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



lauthiamkok
07-19-2009, 03:58 AM
Hi,

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,
Lau

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;
}
}
</script>


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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum