JSFiddle - React, Tailwind, and code Playground
by Graham Fairweather
HTML
<select id="mine">
<option value="test1">Test1</option>
<option value="test2">Test2</option>
<option value="test3">Test3</option>
</select>
<div id="display1">
<div>
<p>Some Text in 1</p>
</div>
<div class="hide">
<p>Some Text in 2</p>
</div>
<div class="hide">
<p>Some Text in 3</p>
</div>
</div>
CSS
.hide {
display: none;
}
JavaScript
document.getElementById('mine').addEventListener('change', (function () {
var children1 = document.getElementById('display1').children,
length1,
index;
return function (evt) {
for (index = 0, length1 = children1.length; index < length1; index += 1) {
if (index === evt.target.selectedIndex) {
children1[index].classList.remove('hide');
} else {
children1[index].classList.add('hide');
}
}
};
}()), false);