$(document).ready(function(){ var sptext = textshow; var spoilero = $(".post div:contains('[spoiler]'), .post p:contains('[spoiler]')"); var spoilerc = $(".post div:contains('[/spoiler]'), .post p:contains('[/spoiler]')").addClass("spclose"); $.fn.spoilerToggle = function(){ $(this).click(function(){ if($(this).parent().siblings(".spoiler").is(":visible") == false){ $(this).parent().siblings(".spoiler").fadeIn('fast'); $(this).text(texthide); }else if($(this).parent().siblings(".spoiler").is(":visible") == true){ $(this).parent().siblings(".spoiler").fadeOut('fast'); $(this).text(textshow); } return false; }); }; spoilero.each(function(){ $(this).nextUntil(".spclose").wrapAll('
') }); spoilero.remove(); spoilerc.remove(); $(".spoiler").hide(); $(".spoiler").wrap(''); $(".spoilercon").prepend(''); $(".spoilerhide").spoilerToggle(); });