View Full Version : Hiding text
Hi everyone!
I've been trying to find a script that hides text!
what I mean, I have a warning sentense that I want to enable the use to dismiss it so it disappears without reloading the page!?
any help out there?
many thanks in advance!
Mo
djr33
05-08-2007, 09:37 PM
That's not very clear, yet.
What is it warning? Is this a user-controlled thing, or will it check something (if there is a plugin, if an image loaded, etc.)?
You should be able to use javascript to change the CSS property of visibility to make it dissapear, though.
<span onclick="this.parentNode.removeChild(this);">Click here to remove this text!</span>
djr33
05-09-2007, 12:58 AM
That's nice. Easy, too.
Might be more fun with:
<span style="background-color: #FFFF00;" onclick="this.parentNode.removeChild(this);">Click here to remove this text!</span>
(though you can do whatever you want, within that span)
am afraid it's not working.
am getting the message "Click here to remove this text!" but plain text without a link, any suggestions? is there something you assume am writing before that?
One more thing, what about if I want to hide the text by clicking on one word not the entire thing, example:
This site has been updated ( dismiss )
here i want the user to be able to click on ( dismiss ) so the sentence before disappears
Many thanks for the help !!
djr33
05-09-2007, 09:45 AM
The message is set with the onClick attribute, so it should dissapear. It works for me, anyway.
It won't seem to be a link, though you could format it as such (underline, cursor: hand;, etc.), or make it a link to "#", etc.
As for (dismiss), that might be harder.
I'm guessing, on the span tag, then, use:
onclick="this.parentNode.parentNode.removeChild(this);"
tech_support
05-09-2007, 09:55 AM
<a href="#" onclick="this.parentNode.removeChild(this);">Click here to remove this text!</a>
Many thanks, problem solved!
cheers, Moh
codeexploiter
05-09-2007, 03:29 PM
Or the following one
<span onclick="this.parentNode.removeChild(this);" style="text-decoration:underline;" onmouseover="this.style.cursor='hand';this.style.cursor='pointer';">Click here to remove this text!</span>
codeexploiter's is preferable... it's not a link, so using <a> is an abuse of the element, and may confuse people without Javascript.
onclick="this.parentNode.parentNode.removeChild(this);"Not quite...
<p>
Some text (
<span onclick="this.parentNode.parentNode.removeChild(this.parentNode);">
dismiss
</span>
)
</p>
tech_support
05-10-2007, 10:35 PM
Really?
Most websites I see use <a>.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.