tags:

views:

274

answers:

2

Hi this should be a really easy problem but i am stuck. Is it possible to fade out the text inside a text box and textarea and leave the actual element in place. I have tried fading out using .html() .val() etc but the element that the text is in is always faded too.

+4  A: 

I think the only way to achieve this is by manipulating the input element's colour. Check out the JQuery color plugin that specializes in colour manipulations.

It should work along the lines of

$(formelement).animate({ color: "#FFFFFF" }, 600);
Pekka
hey thanks for the suggestion. i tried to change it to white and then just remove the val() but it didnt really fade to the white color
David
Can you post an on-line example to check out?
Pekka
A: 

Simply surround the text in a span and fade the span. JQuery will fade the element, this is the easiest way. I am not sure there is a way to fade just text and not the entire DOM element.

Edit: Didn't read the textarea part. To do this you'll probably want to hide the actual input element and style a new one to look like a text element, and then fade the text inside it. This is commonly done to restyle the look of an input element.

Jeremy B.
Won't work for content inside a text/textarea form element.
Pekka
First part won't, second part will, thus the edit.
Jeremy B.
thanks ill try that - i just assumed there would be an easy way of doing it.
David