誰能告訴我,爲什麼我總是收到「displaymessage沒有定義」與此代碼錯誤信息。在此先感謝:)爲什麼我總是收到「displaymessage is not defined」的錯誤信息?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TEST PAGE</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
function displaymessage() {
alert("Hello World!");
}
});
</script>
</head>
<body>
<p><input type="button" name="start" id="start" value="start" onclick="displaymessage()" /></p>
</body>
</html>
太好了 - 工作:將定義移出$(document).ready(function(){...} ..謝謝;) – MWD 2012-02-16 02:45:11