Jquery textarea value focus?

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.

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: Enter text here 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.

Jquery_example plugin do exactly what you need. You may have a look at its source code and get some inspiration. Or you can store the default value as meta-data on the tag and check against it on change event of the textarea tag.

Try $('#comment'). Live('click change focus', function() { var $txt = $(this).val(); if($txt == 'Enter your comment' ); $(this). Val(''); }); DEMO.

Not what I'm after, it clears the value no matter what the value is. Thanks for the effort though. – Brogrammer Apr 19 at 4:47 ok then comment initial two lines..this will clear whatever is written.

See here : jsfiddle. Net/Em4je/2 – diEcho Apr 19 at 4:51 Clearing 'no matter what the value is' was not what I was after. Thanks anyway.

– Brogrammer Apr 19 at 4:56.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions