Reputation: 11629
It is perhaps a very simple question, but I want to fadeOut a text inside a textarea (<textarea id="text">blabla</textarea
) without 'fadingOut' the textarea itself, using jquery.
I tried to use $('text').val(), $('text').text(), or document.getElementById("text").nodeValue;
But nothing works, the entire textarea 'displays none'. Does anyone has an idea ?
Best, Newben
Upvotes: 0
Views: 588
Reputation: 952
jQuery methods such as .text() and .val() return the value of what's contained in the relevant HTML element, not a pointer to the actual text in the element. That's why using them isn't working for what you want.
You should be able to get the effect you want using jQuery UI and its .ToggleClass() method. Set up a css class where the textarea's color is the same as its background, and then use .ToggleClass to activate that class on the textarea with a defined duration, which should create an effect that the text inside the textarea is fading away.
Upvotes: 1
Reputation: 1679
There is not an easy way to do this. You could try and animate the color of the text, so basically fade from black to white (if your textarea is white for example), but the user could still highlight the text and see it that way.
The only other solution would be to basically style an image such that it appears like a text area, and replace the text area with that, place the text on top of that inside a div or span and fade the text that way.
Upvotes: 0