| | |
Text box mouseover
Please support our HTML and CSS advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
Hi y'all. I'm just starting to learn HTML and just had a few questions. I was using some tutorials from w3schools.com, and I came across Event Attributes. So I have this textbox, and I want it, when clicked, to clear the the text box of it's value, and change the text color to black (as in the actual text box, not the whole screen). Then when you click out of the text box, I want it to change the text color back to grey and have the value of the text box be 'Email' again. Also, how do I change the font? Here's the code:
Thanks!
html Syntax (Toggle Plain Text)
<form> <input type="text" value="Email" name="Email" style="color:grey;text-align:left;background:white"> </form>
Thanks!
Last edited by peter_budo; Dec 3rd, 2008 at 7:32 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
•
•
Join Date: Jan 2008
Posts: 57
Reputation:
Solved Threads: 5
Some of that (changing the colors of the text and whatnot) you can do with CSS styles. The rest (changing the actual text) requires that you use a scripting language like Javascript.
For the styling (changing text color, background color, etc) you can apply a style to input buttons. With pseudo classes, you can have that style change based on whether it's being targeted (in focus) or not.
For example, put this in the <head> section of your page, and test it out with an <input type="text"> element...
The style applied to input:focus will only be applied when the input class is selected. The rest of the time, it will display what is declared for all inputs, and so it looks like it's inactive.
To alter the text inside the input, you'll need to use javascript. Posting in the javascript forum might get you some more specific help, but here's a nudge in the right direction.
Get a javascript framework, like jquery, to make it easier to select elements from the DOM.
jQuery has two methods to help you. The focus() method will trigger when an item is selected, and at that point you could clear the input and alter its style. The blur() method will trigger when the focus leaves the input, and at that point you could replace the text with "E-mail" and alter the style again.
Good luck,
- Walkere
For the styling (changing text color, background color, etc) you can apply a style to input buttons. With pseudo classes, you can have that style change based on whether it's being targeted (in focus) or not.
For example, put this in the <head> section of your page, and test it out with an <input type="text"> element...
html Syntax (Toggle Plain Text)
<style type="text/css"> input { color: #ccc; background-color: #eee; } input:focus { color: #000; background-color: #fff; } </style>
The style applied to input:focus will only be applied when the input class is selected. The rest of the time, it will display what is declared for all inputs, and so it looks like it's inactive.
To alter the text inside the input, you'll need to use javascript. Posting in the javascript forum might get you some more specific help, but here's a nudge in the right direction.
Get a javascript framework, like jquery, to make it easier to select elements from the DOM.
jQuery has two methods to help you. The focus() method will trigger when an item is selected, and at that point you could clear the input and alter its style. The blur() method will trigger when the focus leaves the input, and at that point you could replace the text with "E-mail" and alter the style again.
Good luck,
- Walkere
![]() |
Similar Threads
- Suggestions on this 3 column, tables in Div code (HTML and CSS)
- How to split a large list (Pascal and Delphi)
- On MouseHover events? (Pascal and Delphi)
- Dreamweaver help- how to mouseover images (Graphics and Multimedia)
- <select> options selection on mouse over (JavaScript / DHTML / AJAX)
- VB Script Format (Visual Basic 4 / 5 / 6)
- Mouseover/Rollover (JavaScript / DHTML / AJAX)
- partial classes in 2005: neat but ? on event handlers (C#)
- hover over text tips (JavaScript / DHTML / AJAX)
Other Threads in the HTML and CSS Forum
- Previous Thread: button text...
- Next Thread: Plan for parsing HTML
| Thread Tools | Search this Thread |
appointments asp background backgroundcolor beta browser bug calendar cart cgi code codeinjection corporateidentity css design development displayimageinsteadofflash dreamweaver emailmarketing epilepsy explorer firefox flash form format google griefers hackers hitcounter hover html ide ie7 ie8 iframe image images internet internetexplorer intranet iphone javascript jpeg layout macbook maps marketshare microsoft mozilla multimedia navigationbars news offshoreoutsourcingcompany opacity opera optimization perl pnginie6 positioning problem scroll seo shopping studio swf swf. textcolor timecolor titletags url urlseparatedwords visual visualization web webdevelopment webform website windows7 xml xsl





