Log in

View Full Version : mouseover <textarea>



sdukes
03-11-2006, 05:14 AM
I am using the following code:

<textarea cols="55" rows="15" id="content">Enter your HTML Code Here</textarea><br />
<button onclick="pView()">Preview</button>

Is there a way to remove "Enter your HTML Code Here" when the mouse hovers over the <textarea> box?

jscheuer1
03-11-2006, 08:09 AM
Using onfocus would be better, that way if they mouseover it and aren't even aware they are doing so, the instruction will remain but, as soon as they click on it to enter text, the instruction will disappear. Also, with onfocus, if they move the cursor to the textarea using the tab key, that will also trigger the event:


<script type="text/javascript">
function removecue(obj){
if(obj.value=='Enter your HTML Code Here')
obj.value=''
}
</script>

<textarea cols="55" rows="15" id="content" onfocus="removecue(this);">Enter your HTML Code Here</textarea><br />