Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Posts
    439
    Thanks
    3
    Thanked 0 Times in 0 Posts

    textarea onClick?

    Hi there... Do uknow how i can change the color of a textarea when a user clicks on it? Do u know which browsers support this feauture?Thx

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    <textarea name="t1" onclick="this.style.backgroundColor='red' "></textarea>

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Posts
    439
    Thanks
    3
    Thanked 0 Times in 0 Posts

    thx

    Thx...do u know if this is possible using stylesheets?
    I ask because in this format it is not easy to make changes...

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts
    You can use the css pseudoclass :focus, but the support for it is pretty poor. Check out the support chart for it [here]. I probably shouldn't say that the support is poor, it's just that IE doesn't like it at all.
    Last edited by Antoniohawk; 08-08-2004 at 06:48 PM.

  • #5
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    625
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You want this:

    onclick="this.style.backgroundColor='red'"
    (Background color)


    or this:

    onclick="this.style.color='red'" (text color)



    -james
    "God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    Here is an example of how you can control the appearance of a textarea using CSS and JavaScript event handlers:

    Code:
    <style>
    
    .txt_red{
    	background-color:red;
    	color:white;
    }
    
    .txt_blue{
    	background-color:blue;
    	color:yellow;
    }
    </style>
    
    <textarea class="txt_blue" onfocus="this.className='txt_red'" onblur="this.className='txt_blue'" cols="30" rows="7">The style of this text area is dynamically controlled</textarea>


  •  

    Posting Permissions

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