JSFiddle - React, Tailwind, and code Playground

HTML

<div style="height:3000px; position:relative; margin-top:150px; float:left;">

<span id="subnav" style="background-color:#000; height:20px; color:#fff;  width:1000px; float:left;">hold this</span>
</div>

JavaScript

$(document).ready(function() {
   $(window).scroll(function() {
       var scrollVal = $(this).scrollTop();
        if ( scrollVal > 150) {
            $('#subnav').css({'position':'fixed','top' :'0px'});
        } else {
            $('#subnav').css({'position':'static','top':'auto'});
        }
    });
 });