[英]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.