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 に答える