473,387 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

changing a textarea's bgcolor

Markus
6,050 Expert 4TB
If you take a look at the textarea for commenting on this page you'll see my desire.

When hovering over the textarea the bgcolor changes, but once the textarea is clicked it maintains this new color until the area loses focus.

What's going on guys?

Edit. I posted this in the wrong darn forum!
May 18 '08 #1
9 2831
Atli
5,058 Expert 4TB
You can use the onMouseOver, onMouseOut, onFocus and onBlur events to do this.
You will just have to create a JavaScript variable that indicates whether the input has focus. When it does, prevent the onMouseOut event from changing the color.

Edit. I posted this in the wrong darn forum!
I'll move it over to the JavaScript forums.
May 18 '08 #2
Atli
5,058 Expert 4TB
Or better yet... The CSS :hover and :focus effects
Expand|Select|Wrap|Line Numbers
  1. textarea {
  2.     background-color: #FFFFFF;
  3. }
  4. textarea:hover, textarea:focus {
  5.     background-color: #FFFFCC;
  6. }
  7.  
Doesn't work in IE tho :(
(Grrr @ M$)
May 18 '08 #3
hsriat
1,654 Expert 1GB
Well, its still in the wrong forum :p

Use this css

Expand|Select|Wrap|Line Numbers
  1. textarea.effect, input.effect {
  2.     background-color:#eeeeff;
  3. }
  4. textarea.effect:hover, input.effect:hover,textarea.effect:focus, input.effect:focus {
  5.     background-color:#ffeeee;
  6. }
where effect is the class name of the textareas and input boxes to whom you want to apply this.


[EDIT].. I'm late.. already done by Atli :)
May 18 '08 #4
Velhari
46
Or better yet... The CSS :hover and :focus effects
Expand|Select|Wrap|Line Numbers
  1. textarea {
  2.     background-color: #FFFFFF;
  3. }
  4. textarea:hover, textarea:focus {
  5.     background-color: #FFFFCC;
  6. }
  7.  
Doesn't work in IE tho :(
(Grrr @ M$)
Hi,

This code is working in IE on Strict Mode.
May 19 '08 #5
hsriat
1,654 Expert 1GB
Hi,

This code is working in IE on Strict Mode.
Strict Mode.. .... Strict Doctype?
May 19 '08 #6
acoder
16,027 Expert Mod 8TB
Hi,

This code is working in IE on Strict Mode.
I guess that would be IE7.
May 20 '08 #7
acoder
16,027 Expert Mod 8TB
You can use the onMouseOver, onMouseOut, onFocus and onBlur events to do this.
You will just have to create a JavaScript variable that indicates whether the input has focus. When it does, prevent the onMouseOut event from changing the color.
CSS :hover pseudo-classes are not supported by IE7 unless a doctype is provided, so you will need to use JavaScript to achieve this (if you also need to support IE6).
May 20 '08 #8
Markus
6,050 Expert 4TB
Thanks for all the responses guys!

They all, at a glance, are what I'm looking for.

Wasn't a major thing, just a query.

:)
May 21 '08 #9
This CSS code worked fine for me too in Chrome :)
Feb 16 '12 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John D | last post by:
I am trying to change the background colour of either a div or a textarea with javascript, but am having problems. I have passed a hex colour value in the variable hval, and with the following...
12
by: dan.vendel | last post by:
Hi, I know nothing about javascript, but quite a lot about regulat html and CSS. Have bumped into a problem that people in this fine congregation perhaps can help me with. I'm making a...
12
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in...
15
by: phillip.s.powell | last post by:
<style> div div table tr td a.navbar, div div table tr td font {display: none;} </style> <div class="navigationbar" style="background-color:Black; position: absolute; left:50%; top:127px;...
4
by: Keith Bentrup | last post by:
Hi all, I wrote a simple search function to find text in a textarea where not all the text is visible (ie. the text box displays 10 lines but there may be more than 1000 lines to search). I can...
0
by: lawrenceS59 | last post by:
Hi all, I'm fairly new to web development so bare with me. The html page that i've created isn't working and i can't figure out why. I'm guessing there are some rules that need to be...
0
by: lawrenceS59 | last post by:
Hi all, I'm fairly new to web development so bare with me. The html page that i've created isn't working and i can't figure out why. I'm guessing there are some rules that need to be followed...
10
Markus
by: Markus | last post by:
If you take a look at the textarea for commenting on this page you'll see my desire. When hovering over the textarea the bgcolor changes, but once the textarea is clicked it maintains this new...
15
by: globalrev | last post by:
i have a translator-program for the robbers language. i want the user to input into the topwindow and then display the encryption or decryption in the bottom window. i am currently trying to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.