Fade out text value inside of text field using jQuery

Posted by Dwayne on Stack Overflow See other posts from Stack Overflow or by Dwayne
Published on 2010-06-18T00:04:02Z Indexed on 2010/06/18 0:13 UTC
Read the original article Hit count: 266

Filed under:
|
|

I am not entirely sure if this is possible or not, I am pretty knowledgeable when it comes to jQuery and JavaScript in general, but this one has me stumped. I've created a simple plugin that clears a text input on focus and then displays the default value if nothing has been entered.

Is it possible to fade out just the text itself inside of the text input, and not the whole field itself? All attempts seem to result in the text field itself fading out and eventually hiding the element from view.

I did come up with a solution of using spans containing the default value and absolutely positioning them over the text input, hiding and showing them depending if a user has entered any text or not. I would much rather a much straightforward approach if one exists.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery