I want to hide strings inside a div. Consider the following example where I want to hide “some”.
<div id="Disappear">Here is some text.</div>
After calling the function it should be
<div id="Disappear">Here is text.</div>
Notice that the space remains reserved. Also the sentence and string to be hidden are random.
What have I tried?
Replacing the string with spaces. The solution is not elegant, since the width of the spaces can’t always be equal to the string.
UPDATE I can’t use <span> either. The actual div contains a lot more strings, using span is not an option.
Here’s a quick example – it wraps the search text in a span, which (through css) changes the visibility to hidden
http://jsfiddle.net/4kTVC/1/
Update – as mentioned in comments,
{visibility: hidden}is better than{color: #fff}