...

View Full Version : textarea onClick?



alaios
08-08-2004, 02:51 PM
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

Mr J
08-08-2004, 04:03 PM
<textarea name="t1" onclick="this.style.backgroundColor='red' "></textarea>

alaios
08-08-2004, 04:42 PM
Thx...do u know if this is possible using stylesheets?
I ask because in this format it is not easy to make changes...

Antoniohawk
08-08-2004, 05:44 PM
You can use the css pseudoclass :focus, but the support for it is pretty poor. Check out the support chart for it [here (http://www.macedition.com/cb/resources/css3support_selectors.html)]. I probably shouldn't say that the support is poor, it's just that IE doesn't like it at all.

jamescover
08-08-2004, 07:29 PM
You want this:


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


or this:

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



-james

JohnKrutsch
08-08-2004, 09:46 PM
Here is an example of how you can control the appearance of a textarea using CSS and JavaScript event handlers:



<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>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum