This Forum has been archived

Forums: Admin Central Index Technical Help Censoring spoiler with jQuery
Central's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.
Note: This topic has been unedited for 1659 days. It is considered archived - the discussion is over. Do not add to unless it really needs a response.

Below is the coding to show/hide text with spoilers:

$(function() {
	$('.spoilerContent').click(function() {
	return false;
<span class="spoiler" style="position:absolute">This section contains spoilers.</span>
<span class="spoilerContent" style="opacity:0">Spoiler spoiler spoiler spoiler......</span>

I got the text to appear on clicking, but on second click it doesn't get back, despite return false. What's wrong with this code and how can I fix it?  Cafeinlove msg 2012.06.11. 20:47 (UTC)

Finally I found a solution.
var oddClick = true;
		$(this).andSelf().fadeTo(1000, (oddClick) ? 1 : 0);
		$(this).prev('.spoiler').fadeTo(1000, (oddClick) ? 0 : 1);
	oddClick = !(oddClick);
 Cafeinlove msg 2012.06.12. 07:21 (UTC)
Oh that's fantastic. I won't copy it because I might want to do something slightly different. But still; thanks for the idea! :D STARFLEET ACADEMY 08:10, June 12, 2012 (UTC)