Using jQuery, how do I force a visitor to scroll to the bottom of a textarea to enable the submit button?

前端 未结 5 1976
野的像风
野的像风 2020-12-25 08:50

I have a registration form which contains a read-only textarea. I want to require any visitor to scroll to the bottom of the textarea, which contains terms and conditions or

5条回答
  •  一整个雨季
    2020-12-25 08:55

    Something like this should work:

    $('#terms').scroll(function () {
        if ($(this).scrollTop() == $(this)[0].scrollHeight - $(this).height()) {
            $('#register').removeAttr('disabled');
        }
    });
    

    Simply give terms an id, and set the register button to disabled in the html. I also made a little fiddle to show it working: http://jsfiddle.net/ETLZ8/

提交回复
热议问题