JSFiddle - React, Tailwind, and code Playground

by igor_9000

HTML

<div class="scroll">
<div class="tall">
test
</div>
<div id="t" class="tall">
second
</div>
</div>

CSS

.scroll {
  height: 200px;
  overflow: scroll;
}

.tall { height: 500px; }

JavaScript

mID = 't';

var divToHighlight = document.getElementById(mID);
divToHighlight.style.backgroundColor ="#F5F0C9";
var topPos = divToHighlight.offsetTop;	
divToHighlight.parentElement.scrollTop = topPos;