Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 试图要求用户滚动到段落底部以启用按钮_Jquery_Html - Fatal编程技术网

Jquery 试图要求用户滚动到段落底部以启用按钮

Jquery 试图要求用户滚动到段落底部以启用按钮,jquery,html,Jquery,Html,我试图要求用户滚动到段落底部以启用一个按钮,这与Christian Varga在这里提出并回答的问题几乎相同。由于某种原因,当我使用该代码时,我无法获得相同的结果——我的头信息中是否存在限制我这样做的内容,例如脚本信息 <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edg

我试图要求用户滚动到段落底部以启用一个按钮,这与Christian Varga在这里提出并回答的问题几乎相同。由于某种原因,当我使用该代码时,我无法获得相同的结果——我的头信息中是否存在限制我这样做的内容,例如脚本信息

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<style>

textarea {      
width: 240px;
height: 200px;
overflow-y: scroll;
}

</style>
</head>

<body>

<form action="action.php">
<textarea readonly id="terms">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</textarea>
<button id="agreeButton" disabled>Button</button>
</form>


<script>

var activated = false;
$(document).scroll(function() {
if (!activated) {
var scrolled = $(document).scrollTop() + $(window).height();
var height = $(document).height();
var offset = height - scrolled;

if (offset == 0) {
  activated = true;
  $('#agreeButton').removeAttr('disabled');
    }
  }
});


</script>

</body>
</html>

试验
text区域{
宽度:240px;
高度:200px;
溢出y:滚动;
}
知识产权是一种权利,是一种精英的权利,是劳动和财富的暂时性权利。但是,在最低限度上,我们需要一个实验室来进行日常工作。两人或两人在一个无教区的房间里互相指责。除偶尔因疏忽而死亡外,不得因疏忽而导致动物死亡。知识产权是一种权利,是一种精英的权利,是劳动和财富的暂时性权利。但是,在最低限度上,我们需要一个实验室来进行日常工作。两人或两人在一个无教区的房间里互相指责。除偶尔因疏忽而死亡外,不得因疏忽而导致动物死亡。
按钮
var=false;
$(文档)。滚动(函数(){
如果(!已激活){
var scrolled=$(文档).scrollTop()+$(窗口).height();
var height=$(document.height();
变量偏移=高度-滚动;
如果(偏移量==0){
激活=真;
$(“#agreeButton”).removeAttr('disabled');
}
}
});

这把小提琴的起源。我基本上清除了除标题信息之外的所有内容,但没有使其正常工作。

您缺少了强制禁用按钮的js,直到它们滚动为止。如果不加载,它将不会生效。

您缺少强制禁用按钮的js,直到按钮滚动为止。如果不加载它,它将不会生效。

您还需要使用jQuery 2.1.1。
var-activated=false;
$(文档)。滚动(函数(){
如果(!已激活){
var scrolled=$(文档).scrollTop()+$(窗口).height();
var height=$(document.height();
变量偏移=高度-滚动;
如果(偏移量==0){
激活=真;
$(“#agreeButton”).removeAttr('disabled');
}
}
});


按钮
您还需要使用jQuery 2.1.1。
var-activated=false;
$(文档)。滚动(函数(){
如果(!已激活){
var scrolled=$(文档).scrollTop()+$(窗口).height();
var height=$(document.height();
变量偏移=高度-滚动;
如果(偏移量==0){
激活=真;
$(“#agreeButton”).removeAttr('disabled');
}
}
});


按钮
我使用的JS来自这个工作示例。你是在建议我需要额外的JS吗?是的。你没有加载它。基于html,您所加载的只是引导和jQuery。你是在建议我需要额外的JS吗?是的。你没有加载它。基于你的html,你所加载的只是引导和jQuery。在添加你给我的建议后,我不确定我是否以正确的方式设置了它,因为我似乎仍然缺少一些东西…在添加你给我的建议后,我不确定我是否以正确的方式设置了它,因为我似乎仍然缺少一些东西。。。