JSFiddle - React, Tailwind, and code Playground
by Daniel Hall
HTML
<div id="inputWords">
<ul>
<li>
<input type="text" id="adj1">
<br>
</li>
<!-- put other input fields her -->
</ul>
</div>
<div id="story">
</div>
<button id="replaceButton">Start</button>
CSS
body {
font-family: "Comic Sans MS";
}
#inputWords {
float:left;
width: 45%;
}
ul {
list-style-type: none;
padding: 0px;
margin: 0px;
}
li {
line-height: 2em;
text-transform: uppercase;
margin-top: 8px;
}
input[type=text] {
border-width: 0 0 1px 0;
border-color: #333;
}
#buttonDiv {
text-align: center;
}
#replaceButton {
margin-top: 30px;
width: 200px;
}
#story {
margin-top: 12px;
width: 45%;
border: 1px dashed blue;
padding: 8px;
float: left;
}
.replacement {
text-decoration: underline;
text-transform: uppercase;
}
JavaScript
var replaceButton = document
.getElementById("replaceButton");
replaceButton.addEventListener("click",replaceIt);
function replaceIt() {
var storyDiv = document.getElementById("story");
var adj1 = "<span class='replacement'>"+ document
.getElementById("adj1").value + "</span>";
/* Insert more varible definitions here */
var theStory = "<h1>Douglas's Dance Party</h1>";
theStory += "One " + adj1 + " day,";
/* Put the the story here, using the +=
operator */
storyDiv.innerHTML = theStory;
}