这是我正在使用的html。我试图找出为什么我的按钮和复选框永远不会被设置为启用。
<form id="form1" runat="server">
<script src="js/mootools-core-1.3.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(function checkScrollHeight() {
var textElement = document.getElementsByName("tosgareementdiv")[0].addEventListener("scroll", checkScrollHeight, false);
if ((textElement.scrollTop + textElement.offsetHeight) >= textElement.scrollHeight) {
document.getElementsByName("AcceptTOSButton")[0].disabled = false;
}
});
</script>
<div class="tosgareementdiv">
<p>hi my stuff</p>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br><br><br>
<br>
<br>
<br>
<br>
<asp:CheckBox ID="AcceptTOSCheckBox" Text="I Agree." runat="server" Enabled="false" />
<asp:Button ID="AcceptTOSButton" Text="I Agree" runat="server" OnClick="AcceptTOSButton_Click"
Enabled="false" />
</div>
</form>
我在这里遵循这个例子,但我无法弄清楚如何解决它......
我知道复选框没有代码,但为什么按钮不启用?
答案 0 :(得分:0)
试试这个
<script type="text/javascript">
$(function(){
function checkScrollHeight() {
if ((textElement.scrollTop + textElement.offsetHeight) >= textElement.scrollHeight) {
document.getElementById("AcceptTOSButton").disabled = false;
}else{
document.getElementById("AcceptTOSButton").disabled = true;
}
};
var textElement = document.getElementsByClassName("tosgareementdiv")[0];
textElement.addEventListener("scroll", checkScrollHeight, false);
});