为什么这个Javascript没有运行?

时间:2012-11-10 05:36:18

标签: javascript jquery

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

2 个答案:

答案 0 :(得分:6)

脚本标签不是自动关闭的。您必须<script src='...'></script>

答案 1 :(得分:1)

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

$(document).ready(function()
{
    alert("Document is ready!");
    $("#documentList").remove();
    alert("Removed the list.");
 });