JSFiddle - React, Tailwind, and code Playground
by Nick Craver
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">
<div id="test" class="minimized">Original Text Here</div>
CSS
div { width: 300px; height: 200px; border: solid 1px #ddd; cursor: pointer; }
JavaScript
var el = document.getElementById("test");
el.onclick = function(){
if(this.className.indexOf("minimized") != -1){
this.originalText = this.firstChild.nodeValue; //store original
this.firstChild.nodeValue = 'turn back'; //change it
this.className = this.className.replace("minimized", 'expanded');
}
else if(this.className.indexOf("expanded") != -1){
this.firstChild.nodeValue = this.originalText; //restore it
this.className = this.className.replace("expanded", 'minimized');
}
}