Sorry if i am soiling this thread with my another code snippet, but here goes.
Replace this:
$(function () {
$('.spoiler').css('display', 'none');
$('.spoiler_trigger').click(function () {
var hideText = 'Hide Spoiler', showText = 'Show Spoiler';
var $this = $(this);
var $thisSpoiler = $this.next('.spoiler');
var text = $this.text();
var newText = text === showText ? hideText : showText;
$thisSpoiler.toggle('blind');
$this.text(newText);
});
});
With this (remove comments
):
$(function () {
// should be in css, should use hide() function instead (faster)
$('.spoiler').css('display', 'none');
// new-ish good practice is to use on() instead of click(), on() allows easy event namespacing and deferring if needed
$('.spoiler_trigger').on('click', function () {
// cleaned up declared variables that are used only once
var hideText = 'Hide Spoiler', showText = 'Show Spoiler',
$this = $(this),
newText = $this.text() === showText ? hideText : showText;
// this animate thingy should be in, for example UI, namespace and share logic with livestreams one
$this.next('.spoiler').stop().animate({ height:'toggle', opacity:'toggle'}, 'fast');
$this.text(newText);
});
});