我使用的是Mac OS 10.6,Chrome 34和jQuery 2.1.1。 我有这个从TutsPlus'30天学习jQuery'的简单代码。 我声称有jQuery中的错误。 或...你告诉我! ;)Jquery - > Document.Ready - >不会触发
这不起作用:
<html>
<head>
<title> Does not work </title>
<script type="text/javascript" src="jquery-2.1.1.js"></script> //script is in root
<style>
.emphasis{font-weight: bold;}
</style>
<script>
$(document).ready(function()){$('li:first-child').addClass('emphasis');});
</script>
</head>
<body>
<ul>
<li>Hello</li>
<li>Hello 2</li>
<li>Hello 3</li>
</ul>
</body>
</html>
这工作:
<html>
<head>
<title> </title>
<script type="text/javascript" src="jquery-2.1.1.js"></script>
<style>
.emphasis{font-weight: bold;}
</style>
</head>
<body>
<ul>
<li>Hello</li>
<li>Hello 2</li>
<li>Hello 3</li>
</ul>
<script>
$('li:first-child').addClass('emphasis');
</script>
</body>
</html>
语法错误'$(文件)。就绪(函数(){ $( '李:第一胎')。addClass( '重点'); });' - 额外')'在'function())' –
嗨,谢谢你的答案。我可以问你一下,你能推荐一个有语法检查的编辑吗? – InnerOrchestra
有很多编辑... Dreamviewer可能是我认为...或者你有aptana –