今天写了第一个JQuery程序,发现就跑步起来,很奇怪,查看后也正确的引入了JQuery包,不知道是为什么,最后终于发现问题,奇怪的很。
错误的代码:
1: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 2: "http://www.w3.org/TR/html4/loose.dtd"> 3: <html> 4: <head> 5: <title>My First JQuery example</title> 6: <script language="JavaScript" type="text/javascript" src="lib/jquery-1.6.3.js"/> 1: 2: <script> 3: $(document).ready(function(){ 4: alert("Welcome to come JQuery World!"); 5: }); 6: </script> 7: </head> 8: <body> 9: <h1>This is the first JQuery example!</h1> 10: </body> 11: </html>.csharpcode, .csharpcode pre{ font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt { background-color: #f4f4f4; 100%; margin: 0em;}.csharpcode .lnum { color: #606060; }
上述代码中第六行是错误的,script必须成对的出现。
<script language="JavaScript" type="text/javascript" src="lib/jquery-1.6.3.js"></script>
这样才是正确的。