0

这是我正在使用的 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>

我在这里按照示例进行操作,但我无法弄清楚如何启动它..

我知道复选框没有代码,但为什么按钮不能启用?

4

1 回答 1

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);
});

于 2013-05-16T17:48:07.307 回答