Give this a shot
<!DOCTYPE html>
<html>
<head>
<style>
p{
margin-top : 150px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(window).on('scroll',function(){
var a = $(window).scrollTop();
//alert(a);
if( a > 50) {
$("p").css("textDecoration", "underline");
}
else {
$("p").css("textDecoration", "none");
}
});
});
</script>
</head>
<body>
<div>
<p>As you scroll, I'll underline myself.</p>
<p>As you scroll, I'll underline myself.</p>
<p>As you scroll, I'll underline myself.</p>
<p>As you scroll, I'll underline myself.</p>
</div>
</body>
</html>
You might also want to check out the example here.