JSFiddle - React, Tailwind, and code Playground

by Gereltod Gotsbayar

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jQuery-slimScroll/1.3.6/jquery.slimscroll.js"></script>
test<br />
test<br />
test<br />
test<br />
<ul></ul>

CSS

.root {
    display: block
}
li a {
    color: #444;
    text-decoration: none;
}
li.active a {
    color: red; /* yes, sweet red */
    font-weight: bold;
}

JavaScript

$(function () {
    
    for (i = 0; i <= 200; i++) {
        $("ul").append("<li class='el_"+i+"'><a href='#'>element "+i+"</a></li>");
    }
        
    var random_el = Math.floor((Math.random() * 200) + 1);
    $("ul li.el_"+random_el).addClass("active");
    
    var abs_height = $("ul li.active").offset().top - $("li").height();
    alert(random_el);
    //$('ul').slimScroll({  scroll: '50px'  });
    
    var scrollTo_int = $('ul li.active').prop('scrollHeight') + 'px';
    $('ul').slimScroll({scrollTo : scrollTo_int });
})