JSFiddle - React, Tailwind, and code Playground
by deathstalkersid
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body style="height: 200vh;">
<div class='reveal_section' style="height: 100px; background-color: aqua;">
<div class="reveal_content" style="height: 10px; background-color: yellow; display: none;"></div>
</div>
<div class='reveal_section' style=" height: 100px; background-color: blue;">
<div class="reveal_content" style="height: 10px; background-color: green; display: none;"></div>
</div>
<script>
const els = document.querySelectorAll('.reveal_section');
Array.from(els).forEach((el) => {
el.addEventListener('click', (event) => {
const currentEl = event.currentTarget;
const child = currentEl.querySelector('.reveal_content');
child.style.display = 'block';
child.scrollIntoView({ behavior: 'smooth' });
});
});
</script>
</body>
</html>