我在以下代码中遇到问题:
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=PT+Sans' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=PT+Sans:700' rel='stylesheet' type='text/css'>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
</head>
<body>
<input type = "button" value = "test" />
<script>
function firstload() {
alert("start");
$(document).ready(function () {
alert("foo");
});
alert("end");
}
addEventListener('load', function () {
'use strict';
setTimeout(firstload, 0);
}, false);
</script>
</body>
</html>
当我做了一些工作时,我没有发现代码有什么问题。
上面的代码保存为php,但保存为html时甚至不工作。
我从来没有达到 alert("end") 语句,也从来没有达到 alert("foo") 语句。
如何使用 $(docuemnt).ready 编写一些代码。