谁能告诉我,为什么我总是收到“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