AboutAndrew Hoffman Expertise I can field just about any question within this topic ranging from JavaScript to CSS, the two ingredients of DHTML. I`m very interested in the W3C and its validation rules for HTML, XHTML, and CSS, and enjoy answering questions of this type as well. I detest sleep and respond at all hours of the day or night.
Experience Experience in the area I've been working with DHTML and CSS for 7 years now and build/maintain websites of my own that implement DHTML navigation.
What I'm doing now My contract with Microsoft has ended and I am working for myself once again. Please contact me for any front-end work at antibland@gmail.com
In the search bar,the default value is "Gaurav Srivastav".
I want that the text "Gaurav Srivastav" should be written in color rgb(137,137,137)and when somebody click in the search box the text must disappear,and the person using the website can enter the search string in the search box in black colour.
Is it possible
Answer Gaurav, run this code in any browser to test this solution. Basically, you want to add this to your loading code, if any exists already. The code first looks through all <input> fields and finds the one named "q". Next it sets the starting string color of "q" to rgb(137, 137, 137). If the user enters the field "q" then the text will disappear ONLY IF the string value is "Gaurav Srivastav". If not, this means the user has already entered some text in the field, left, and come back to the field again. In this case, we don't want that text to disappear. Finally, I assign event listeners to the input field so that it toggles correctly and alternates text colors as you requested.