javascript - Variable doesn't work inside JQuery scroll function -


my goal create , display variable record scroll position. while scroll function seems working (for example can alert message inside it) when add scroll_pos variable stops working. have followed tutorial https://www.youtube.com/watch?v=awgodllsgwu don't understand what's wrong code. use <div id="'status> display variable. suggestions? here's code https://jsfiddle.net/avxgeeah/

$(document).ready(function(){      $("#text_area").scroll(function(){         var scroll_pos = $(this).scrolltop();         alert(scroll_pos);     }); }); 

it works here https://jsfiddle.net/j5vg0fsj/

$("#target").scroll(function(){     var scroll_pos = $(this).scrolltop();     alert(scroll_pos); }); 

i know chrome offer disable alerts if firing frequently. perhaps okayed that?


Comments