0

我无法对这里发生的事情做出一些合乎逻辑的理解,有人可以帮我吗?

// 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>
4

1 回答 1

6

这很简单。它会禁用复选框并保持这种状态,直到您向下滚动到内容的末尾。没什么特别的 :) 您可以在您必须在接受许可证之前阅读许可证的页面上看到它。

于 2012-12-29T09:46:29.117 回答