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!
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.
Atli 5,058
Expert 4TB
Or better yet... The CSS :hover and :focus effects -
textarea {
-
background-color: #FFFFFF;
-
}
-
textarea:hover, textarea:focus {
-
background-color: #FFFFCC;
-
}
-
Doesn't work in IE tho :(
(Grrr @ M$)
Well, its still in the wrong forum :p
Use this css - textarea.effect, input.effect {
-
background-color:#eeeeff;
-
}
-
textarea.effect:hover, input.effect:hover,textarea.effect:focus, input.effect:focus {
-
background-color:#ffeeee;
-
}
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 :)
Or better yet... The CSS :hover and :focus effects -
textarea {
-
background-color: #FFFFFF;
-
}
-
textarea:hover, textarea:focus {
-
background-color: #FFFFCC;
-
}
-
Doesn't work in IE tho :(
(Grrr @ M$)
Hi,
This code is working in IE on Strict Mode.
Hi,
This code is working in IE on Strict Mode.
Strict Mode.. .... Strict Doctype?
Hi,
This code is working in IE on Strict Mode.
I guess that would be IE7.
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).
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.
:)
This CSS code worked fine for me too in Chrome :)
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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;...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |