首页 > JavaScript > 文章正文

js设置用户必须阅读完全文才可以勾选同意协议

更新时间:2020-12-13

获取到当前元素,然后获取当前元素的高度、滚动条距离顶部高度,滚条高度,从而进行判断。
代码如下:

that.$nextTick(() => {
    const el = document.querySelector('.reg-pro-wrap');
    const offsetHeight = el.offsetHeight;
    el.onscroll = () => {
        const scrollTop = el.scrollTop;
        const scrollHeight = el.scrollHeight;
        if ((offsetHeight + scrollTop) - scrollHeight >= -1) {
            // 需要执行的代码
            console.log('已滚动到底部')
            that.disabled = false;
        }
    };
});
相关文章
相关标签