User:Najzere/spoilerimage.js

$(document).ready(function { $('span.spoilerimage img').each( function { var spWidth=(parseFloat($(this).attr('width').substring(0,$(this).css('width').length-2))/2)+25; var spHeight=(parseFloat($(this).attr('height').substring(0,$(this).css('height').length-2))/2)-6; alert(spHeight); var hiddensrc=$(this).attr('src'); var spoilersrc='http://cdn.wikimg.net/strategywiki/images/b/be/Yellow-background-24x24.png'; $(this).attr('src',spoilersrc); var $spoilerImage=$(' '); $(this).parent.append($spoilerImage); $(this).parent.css({     position: 'relative',      left: '0',      top: '0'    }); $(this).css({     position: 'relative',      left: '0',      top: '0'    }); $spoilerImage.css({     position: 'relative',      left: Math.round(-spWidth),      top: Math.round(spHeight)    }); $(this).attr({     onMouseOver: "$(this).attr('src','"+hiddensrc+"'); $(this).next.css('display','none');",      onMouseOut: "$(this).attr('src','"+spoilersrc+"'); $(this).next.css('display','');"    }); }); });