为什么$(文件)。就绪(函数()......本例中没有工作?
问题描述:
为什么$(文件)。就绪(函数()在下面的例子不工作?
如果我把它拿出来,其他的jQuery语句的工作
alt text http://i36.tinypic.com/dmb9yg.jpg
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<title>Text Page</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("jquery", "1.3.2");
$(document).ready(function() {
$("p").css("background-color","green");
});
function highlightIt() {
$("p").css("background-color","yellow");
}
</script>
</head>
<body>
<p>this is a test</p>
<form action="">
<div>
<input type="button" value="highlight it" onclick="highlightIt()" />
</div>
</form>
</body>
</html>
答
对于谷歌加载,你必须使用:
google.setOnLoadCallback(function() {
$(document).ready(function() {
// Do something
});
});
很高兴知道,谢谢 – 2009-09-26 13:39:47