2

这是我正在使用的 HTML 文件。我不知道为什么 JS 不运行。控制台不打印任何错误。想法?

<!doctype HTML>
    <html>
    <head>
        <title>ProjectShare</title>
        <!-- <script src = "socket.io/socket.io.js"></script> -->
        <script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"/>
        <script>
            //Make sure DOM is ready before mucking around.
            alert("Before jQuery.");
            $(document).ready(function()
            {
                alert("Document is ready!");
                $("documentList").remove();
                alert("Removed the list.");
            });
            alert("After jQuery.");
        </script>
        <!-- <script type="text/javascript" src = "https://raw.github.com/jashkenas/coffee-script/master/extras/coffee-script.js"></script> -->
    </head>
    <body>
        <ol>
            <li><a href="index.html">ProjectShare</a></li>
            <li><a href="guidelines.html">Guidelines</a></li>
            <li><a href="upload.html">Upload</a></li>
            <li>
                <form>
                    <input type = "search" placeholder = "enter class code"/>
                    <input type = "submit" value = "Go"/>
                </form>
            </li>
        </ol>
        <ol id = "documentList">
            <li>document1</li>
            <li>document2</li>
        </ol>
    </body>
    </html>
4

2 回答 2

6

脚本标签不会自动关闭。你必须这样做<script src='...'></script>

于 2012-11-10T05:38:03.563 回答
1

此外,您必须使用有效的选择器:

$(document).ready(function()
{
    alert("Document is ready!");
    $("#documentList").remove();
    alert("Removed the list.");
 });
于 2012-11-10T05:40:10.250 回答