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

前端 未结 5 1996
野的像风
野的像风 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 09:09

    Christian Varga's solution is absolutely correct, and can also be applied to a div. However, if you are using a div instead of a textarea, the div MUST NOT have any padding on it or it breaks.

    My workaround for this was to place a div inside my styled div (with padding, rounded corners, and a border) to detect scrolling. So:

    Lorem ipsum...terms text...

    The only possible drawback to this approach is if you add padding to the containing div, the scrollbar appears on the inner div, which may not look good to some users.

提交回复
热议问题