簡體   English   中英

為什么這個Javascript沒有運行?

[英]Why does this Javascript not run?

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

腳本標簽不是自動關閉的。 你必須做<script src='...'></script>

此外,您必須使用有效的選擇器:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM