Ok first off you should only have one tag with the id of comment since ids are supposed to be unique, but if we go with your code you have to setup a default value first like this:
<textarea id="comment">Enter text here</textarea> Now the javascript:
(function() { $('textarea#comment').each(function() { var $txt = $(this).val(); //alert($txt); $(this).bind('focus', function() { if($(this).val() === this.defaultValue) { $(this).val(''); } }); }); })(); })();
The self executing function syntax has been corrected here and should be as follow:
(function () { // my code here })(); and for default value use:
this.defaulValue; // works for input boxes as well Hope it helps. Cheers