JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li>Don't ROT13 this text.</li>
<li class="spoilerText">This text should be obfuscated.</li>
<li>Part of this text <span class="spoilerText">should be obfuscated</span>.</li>
</ul>
CSS
.spoilerText {
cursor: pointer;
background: #ff0;
}
JavaScript
function rot13(s) {
// credit: http://stackoverflow.com/a/617685/1481489
return s.replace(/[a-zA-Z]/g,function(c) {
return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);
});
};
$('.spoilerText').each(function(s) {
var $this = $(this);
$this.text(rot13($this.text()));
}).click(function() {
var $this = $(this);
$this.text(rot13($this.text()));
});