Results 1 to 2 of 2

Thread: mouseover <textarea>

  1. #1
    Join Date
    Mar 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default mouseover <textarea>

    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?

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    Code:
    <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 />
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •