<div class="wrap">
<div class="wrap__el">
<div class="info">
<ul>
<li>Lorem Ipsum is simply dummy text</li>
<li>Lorem Ipsum is simply dummy text</li>
</ul>
</div>
</div>
<div class="wrap__el">
<div class="info">
<ul>
<li>It is a long established fact that a reader</li>
<li>It is a long established fact that a reader</li>
</ul>
</div>
</div>
<div class="wrap__el">
<div class="info">
<ul>
<li>Contrary to popular belief</li>
<li>Contrary to popular belief</li>
</ul>
</div>
</div>
</div>
<div class="result"></div>
.wrap {
display: flex;
}
.wrap__el {
width: 33%;
}
.wrap__el, .result {
margin: 20px 10px;
border: 10px solid #ffa500;
}
.result {
border-color: #000;
}
.active {
border-color: #ff0000;
}
var output = document.querySelector(".result");
var clickEl = document.getElementsByClassName("wrap__el");
for (var i = 0; i < clickEl.length; i++) {
clickEl[i].addEventListener("click", function() {
var x = document.getElementsByClassName("wrap__el");
Array.prototype.forEach.call(x, function(el) {
el.classList.remove("active");
output.innerHTML = '';
});
this.classList.add('active');
output.innerHTML = this.innerHTML;
});
}
const Block = ({ items }) => (
<div className="info">
<ul>{items.map(n => <li>{n}</li>)}</ul>
</div>
);
class App extends React.Component {
state = {
items: [
[ 'hello, world!!', '69' ],
[ 'fuck the world', '187' ],
[ 'fuck everythign', '666' ],
],
selected: null,
}
onClick = e => {
this.setState({
selected: +e.currentTarget.dataset.index,
});
}
render() {
const { items, selected } = this.state;
return (
<div>
<div className="wrap">
{items.map((n, i) => (
<div
className={`wrap__el ${i === selected ? 'active' : ''}`}
onClick={this.onClick}
data-index={i}
>
<Block items={n} />
</div>
))}
</div>
<div className="result">
{selected !== null ? <Block items={items[selected]} /> : null}
</div>
</div>
);
}
}