$(".spoiler").click(function() { if($(this).data(content) != undefined) { $(this).html($(this).data(content)); }}// Provided that $(".spoiler").data(content) contains the spoilered text