I would like to have something like <textarea>Welcome, click here to type.</textarea>
Then clear when the user clicks on the text area, obviously.
But.
Before anyone mentions that there are duplicates of this question on this site already there are other details that are not mentioned in the answers. For example:
I've seen that it's possible to clear <textarea> without onclick() and only having an <textarea id="someid">. I just don't know how they did it, I would like to do this. Not only do I like my code clean but I'd like to know how this was possible. (I'm thinking onClick() somehow being inside the <head><script type="text/javascript"></script></head>?)
I also want the <textarea> to not clear once someone has typed something and clicks on the text area again. i.e. When the user clicks the text area again to edit a certain part of the text entered.
I don't know much Javascript but this is the way I see it working:
- If
<textarea>matches the valueWelcome, click here to type; it should clear the text once the user clicks in the text area. - If
<textarea>is empty and is no longer on focus it should return the value "Welcome, click here to type." again.
This means clicking on the text area again wouldn't clear the text, which prevents the text from being cleared once the user has already typed something in the box.
Thanks in advance for helping me out! Your knowledge on this matter would be greatly appreciated. :)