我无法对这里发生的事情做出一些合乎逻辑的理解,有人可以帮我吗?
// heynow.js
$(document).ready(function() {
// on the checkbox disable it right away
$('#agree').attr('disabled', 'disabled');
//on the terms box add a scroll function
$('#terms').scroll(function() {
// textareheight equals scrollheight not accurate
var textareaheight = $(this).[0].scrollHeight;
// scrollheight equals scrollheight – the innerheight which is more accurate and dynamic
var scrollheight = textareaheight - $(this).innerHeight();
// scrolltop equals scrolltop returning where are you
var scrolltop = $(this).scrollTop();
// if where you at equals the total height
if (scrolltop == scrollheight) {
// then enable the checkbox
$('#agree').removeAttr('disabled');
}
});
});
<!-- html file -->
<p><textarea id="terms">lots of text for a scroll avail</textarea></p>
<p><input id="agree" type="checkbox" /> I Agree</p>